Skip to content
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

[jest-worker]: bigInt serialization in jest-worker #11624

Closed
wants to merge 6 commits into from

Conversation

sauravhiremath
Copy link
Contributor

@sauravhiremath sauravhiremath commented Jun 30, 2021

Summary

Resolves #11617
Adds serialization support for BigInt Type - when passing messages through jest-worker processes (parallel runs not using worker-threads)

Test plan

  • [jest-worker] Add a wrapper BigIntSerialization for messages sent through jest-worker

Update

@sauravhiremath sauravhiremath changed the title fix: bigInt serialization [jest-worker]: bigInt serialization in jest-worker Jun 30, 2021
@codecov-commenter
Copy link

Codecov Report

Merging #11624 (4f7cd03) into master (edf2803) will decrease coverage by 0.00%.
The diff coverage is 66.66%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master   #11624      +/-   ##
==========================================
- Coverage   69.01%   69.01%   -0.01%     
==========================================
  Files         312      312              
  Lines       16335    16339       +4     
  Branches     4734     4735       +1     
==========================================
+ Hits        11274    11276       +2     
- Misses       5033     5035       +2     
  Partials       28       28              
Impacted Files Coverage Δ
packages/jest-worker/src/workers/messageParent.ts 38.46% <0.00%> (ø)
packages/jest-worker/src/index.ts 97.91% <75.00%> (-2.09%) ⬇️
packages/jest-worker/src/workers/processChild.ts 94.11% <100.00%> (ø)
packages/expect/src/utils.ts 95.58% <0.00%> (-0.56%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update edf2803...4f7cd03. Read the comment docs.

Copy link
Member

@SimenB SimenB left a comment

Choose a reason for hiding this comment

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

Thanks! Could you add a test and a changelog entry?

Copy link
Member

@SimenB SimenB left a comment

Choose a reason for hiding this comment

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

This seems odd to me - how does only serializing work when we don't deserialize? Isn't the BigInt lost? In which case it'll be reported wrong if passed across a worker

$ node -p 'const JSONbig = require("json-bigint"); JSONbig.parse(JSONbig.stringify({hello: BigInt(42)}));'
[Object: null prototype] { hello: 42 }

I'd like to see a test that sends an object to a worker and receives it back, and verifies they are equal.

This particular module also seems to be failing on Node 10.


Also, at some point we need to add support for circular objects (#10577) for which this module won't work. We can tackle that later of course, just showing that we need to properly serialize/deserialize 🙂

@@ -45,6 +46,10 @@ function getExposedMethods(
return exposedMethods;
}

export function serializerWithBigInt(data: unknown): unknown {
Copy link
Member

Choose a reason for hiding this comment

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

this should not be in index to avoid circular dependencies. Please stick it into a utils, serializers or something

@github-actions
Copy link

This PR is stale because it has been open 1 year with no activity. Remove stale label or comment or this will be closed in 30 days.

@github-actions github-actions bot added the Stale label Sep 20, 2022
@github-actions
Copy link

This PR was closed because it has been stalled for 30 days with no activity. Please open a new PR if the issue is still relevant, linking to this one.

@github-actions github-actions bot closed this Oct 20, 2022
@github-actions
Copy link

This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Please note this issue tracker is not a help forum. We recommend using StackOverflow or our discord channel for questions.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 20, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
4 participants