Skip to content

fix(core): add option to use v8 for daemon message serialization to avoid issues when JSON.stringify would fail #30516

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

AgentEnder
Copy link
Member

@AgentEnder AgentEnder commented Mar 26, 2025

Current Behavior

For really large objects (particularly those containing large strings) JSON.stringify can fail

Expected Behavior

Daemon serialization doesn't fail for the same strings when setting NX_USE_V8_SERIALIZER=true. This should become the default behavior.

Related Issue(s)

Fixes #

Copy link

vercel bot commented Mar 26, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

1 Skipped Deployment
Name Status Preview Updated (UTC)
nx-dev ⬜️ Ignored (Inspect) Visit Preview May 14, 2025 9:59pm

Copy link

nx-cloud bot commented Mar 26, 2025

View your CI Pipeline Execution ↗ for commit ff3e197.

Command Status Duration Result
nx affected --targets=lint,test,build,e2e,e2e-c... ✅ Succeeded 36m 33s View ↗
nx run-many -t check-imports check-commit check... ✅ Succeeded 17s View ↗
nx-cloud record -- nx-cloud conformance:check ✅ Succeeded 2s View ↗
nx-cloud record -- nx format:check ✅ Succeeded 6s View ↗
nx-cloud record -- nx sync:check ✅ Succeeded 5s View ↗
nx documentation ✅ Succeeded 3m 28s View ↗

☁️ Nx Cloud last updated this comment at 2025-05-14 22:42:02 UTC

@AgentEnder AgentEnder force-pushed the fix/core/v8-serialize branch from 91f6d67 to 4c8bfff Compare March 27, 2025 13:36
@AgentEnder AgentEnder marked this pull request as ready for review April 1, 2025 20:38
@AgentEnder AgentEnder requested a review from a team as a code owner April 1, 2025 20:38
@AgentEnder AgentEnder requested a review from Cammisuli April 1, 2025 20:38
Copy link

github-actions bot commented Apr 9, 2025

🐳 We have a release for that!

This PR has a release associated with it. You can try it out using this command:

npx [email protected] my-workspace

Or just copy this version and use it in your own command:

0.0.0-pr-30516-4c8bfff
Release details 📑
Published version 0.0.0-pr-30516-4c8bfff
Triggered by @AgentEnder
Branch fix/core/v8-serialize
Commit 4c8bfff
Workflow run 14366949600

To request a new release for this pull request, mention someone from the Nx team or the @nrwl/nx-pipelines-reviewers.

@AgentEnder AgentEnder force-pushed the fix/core/v8-serialize branch from 4c8bfff to 94d09ba Compare April 15, 2025 14:48
Copy link

🐳 We have a release for that!

This PR has a release associated with it. You can try it out using this command:

npx [email protected] my-workspace

Or just copy this version and use it in your own command:

0.0.0-pr-30516-94d09ba
Release details 📑
Published version 0.0.0-pr-30516-94d09ba
Triggered by @AgentEnder
Branch fix/core/v8-serialize
Commit 94d09ba
Workflow run 14472591662

To request a new release for this pull request, mention someone from the Nx team or the @nrwl/nx-pipelines-reviewers.

…void issues when JSON.stringify would fail

fix(core): v8 serializer should be able to hash tasks

feat(core): use v8 serializer for daemon messages by default
// strings
(message.startsWith('"') && message.endsWith('"')) ||
// numbers
/^[0-9]+(.?[0-9]+)?$/.test(message)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The regex pattern /^[0-9]+(.?[0-9]+)?$/ contains an issue with the decimal point matching. The .? will match any character followed by an optional quantifier, rather than specifically a decimal point. To correctly match an optional decimal point followed by digits, the pattern should be /^[0-9]+(\\.?[0-9]+)?$/ with the decimal point escaped.

Suggested change
/^[0-9]+(.?[0-9]+)?$/.test(message)
/^[0-9]+(\\.?[0-9]+)?$/.test(message)

Spotted by Diamond

Is this helpful? React 👍 or 👎 to let us know.

Comment on lines +331 to +333
`No pending promise found for transaction "${tx}". This may indicate a bug in the plugin pool. Currently pending promises:` +
Object.keys(pending).map((t) => ` - ${t}`)
);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The error message construction will produce unexpected output because Object.keys(pending).map() returns an array that's being concatenated to a string without joining. To properly format the list of pending promises in the error message, use:

`No pending promise found for transaction "${tx}". This may indicate a bug in the plugin pool. Currently pending promises:\n` +
  Object.keys(pending).map((t) => `  -  ${t}`).join('\n')

This ensures each pending promise ID appears on a new line in the error message, making it more readable for debugging.

Suggested change
`No pending promise found for transaction "${tx}". This may indicate a bug in the plugin pool. Currently pending promises:` +
Object.keys(pending).map((t) => ` - ${t}`)
);
`No pending promise found for transaction "${tx}". This may indicate a bug in the plugin pool. Currently pending promises:\n` +
Object.keys(pending).map((t) => ` - ${t}`).join('\n')
);

Spotted by Diamond

Is this helpful? React 👍 or 👎 to let us know.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant