Skip to content

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 #

@vercel
Copy link

vercel bot commented Mar 26, 2025

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

Name Status Preview Updated (UTC)
nx-dev ✅ Ready (Inspect) Visit Preview Jun 30, 2025 8:27pm

@nx-cloud
Copy link
Contributor

nx-cloud bot commented Mar 26, 2025

View your CI Pipeline Execution ↗ for commit 7a66080.

Command Status Duration Result
nx affected --targets=lint,test,build,e2e,e2e-c... ✅ Succeeded 42m 17s View ↗
nx run-many -t check-imports check-commit check... ✅ Succeeded 16s 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 4s View ↗
nx documentation ✅ Succeeded 2m 36s View ↗

☁️ Nx Cloud last updated this comment at 2025-06-30 20:51:22 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
@github-actions
Copy link
Contributor

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
@github-actions
Copy link
Contributor

🐳 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.

@FrozenPandaz FrozenPandaz added the priority: medium Medium Priority (not high, not low priority) label Jun 23, 2025

// Server may send multiple messages in one chunk, so splitting by 0x4
const messages = message.split('');
const messages = message.split(MESSAGE_END_SEQ);
Copy link
Contributor

Choose a reason for hiding this comment

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

There appears to be a logical issue with the message splitting implementation. The code first removes MESSAGE_END_SEQ from the end of the chunk, then attempts to split the resulting message by MESSAGE_END_SEQ. However, since the end sequence has already been removed, this split operation won't find any delimiters in the current message.

To properly handle multiple messages in one chunk, consider either:

  1. Split the original chunk by MESSAGE_END_SEQ before removing the end sequence, or
  2. Remove this split operation entirely if the design only expects one message per chunk after removing the end sequence

This could lead to missed messages if multiple complete messages arrive in a single chunk.

Spotted by Diamond

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

// 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 for matching numbers has an issue with the escaped decimal point. The current pattern /^[0-9]+(\.?[0-9]+)?$/ makes both the decimal point and the digits after it optional, which would incorrectly match strings like "123." (ending with a dot).

A more accurate pattern would be /^[0-9]+(\.[0-9]+)?$/ where only the entire decimal portion (dot + digits) is optional, ensuring that if a decimal point is present, it must be followed by at least one digit.

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.

AgentEnder and others added 5 commits June 30, 2025 15:54
…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
Co-authored-by: graphite-app[bot] <96075541+graphite-app[bot]@users.noreply.github.com>
Co-authored-by: graphite-app[bot] <96075541+graphite-app[bot]@users.noreply.github.com>
Co-authored-by: graphite-app[bot] <96075541+graphite-app[bot]@users.noreply.github.com>
@AgentEnder AgentEnder force-pushed the fix/core/v8-serialize branch from ff075d9 to 0e1173a Compare June 30, 2025 19:56
Comment on lines 331 to 332
`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')
Copy link
Contributor

Choose a reason for hiding this comment

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

There's an issue with the error message construction. Since pending is a Map, using Object.keys(pending) won't work correctly. To properly display the keys from the Map, use Array.from(pending.keys()) instead:

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

Spotted by Diamond

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

@FrozenPandaz FrozenPandaz merged commit a59e6eb into master Jul 9, 2025
8 checks passed
@FrozenPandaz FrozenPandaz deleted the fix/core/v8-serialize branch July 9, 2025 14:53
leosvelperez added a commit that referenced this pull request Jul 10, 2025
…ion to avoid issues when JSON.stringify would fail (#30516)"

This reverts commit a59e6eb.
FrozenPandaz pushed a commit that referenced this pull request Jul 10, 2025
#31881)

…ion to avoid issues when JSON.stringify would fail (#30516)"

This reverts commit a59e6eb.
FrozenPandaz added a commit that referenced this pull request Jul 11, 2025
…void issues when JSON.stringify would fail (#30516)

<!-- Please make sure you have read the submission guidelines before
posting an PR -->
<!--
https://github.com/nrwl/nx/blob/master/CONTRIBUTING.md#-submitting-a-pr
-->

<!-- Please make sure that your commit message follows our format -->
<!-- Example: `fix(nx): must begin with lowercase` -->

<!-- If this is a particularly complex change or feature addition, you
can request a dedicated Nx release for this pull request branch. Mention
someone from the Nx team or the `@nrwl/nx-pipelines-reviewers` and they
will confirm if the PR warrants its own release for testing purposes,
and generate it for you if appropriate. -->

## 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)
<!-- Please link the issue being fixed so it gets closed when this is
merged. -->

Fixes #

---------

Co-authored-by: Jason Jean <[email protected]>
Co-authored-by: graphite-app[bot] <96075541+graphite-app[bot]@users.noreply.github.com>
(cherry picked from commit a59e6eb)
FrozenPandaz pushed a commit that referenced this pull request Jul 11, 2025
#31881)

…ion to avoid issues when JSON.stringify would fail (#30516)"

This reverts commit a59e6eb.

(cherry picked from commit 3782d7e)
@github-actions
Copy link
Contributor

This pull request has already been merged/closed. If you experience issues related to these changes, please open a new issue referencing this pull request.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 15, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

priority: medium Medium Priority (not high, not low priority)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants