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

fix(jest-worker): hangs caused by failed assertions with circular values #15191

Conversation

DmitryMakhnev
Copy link
Contributor

@DmitryMakhnev DmitryMakhnev commented Jul 15, 2024

Summary

Test plan

Unit tests were added

Detailed design

Based on @SimenB’s suggestion to @nodkz’s #14675, I added @ungap/structured-clone for cases where default JSON serialization doesn’t work. @ungap/structured-clone applies only to edge cases to preserve performance for regular cases. @ungap/structured-clone was chosen over flatted flatted because it supports more data structures and also solves the BigInt issue #11617.

If you have any other suggestions, you are welcome.

Copy link

netlify bot commented Jul 15, 2024

Deploy Preview for jestjs ready!

Name Link
🔨 Latest commit 19f66cc
🔍 Latest deploy log https://app.netlify.com/sites/jestjs/deploys/669f5dc63dfcc000080d1faa
😎 Deploy Preview https://deploy-preview-15191--jestjs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@DmitryMakhnev
Copy link
Contributor Author

✅ PR is ready for review

@G-Rath
Copy link
Contributor

G-Rath commented Jul 15, 2024

awesome stuff! it looks pretty good to me though I don't consider myself an expert in this area so I might have missed something 😅

one something that I would recommend considering is making sure there are some tests with complex data such as functions - afaik it's not possible for them to survive serialization (or maybe it's if they use a variable outside of their body...?), but I think it would be good to make sure we've got some tests that show off what happens to ensure everyone understands what's expected (even if that's "the function is destroyed")

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 is awesome, thanks!

Maybe a couple of tests with e.g. function, symbol etc might be a good idea?

@DmitryMakhnev
Copy link
Contributor Author

Hello @G-Rath and @SimenB,

one something that I would recommend considering is making sure there are some tests with complex data such as functions - afaik it's not possible for them to survive serialization (or maybe it's if they use a variable outside of their body...?), but I think it would be good to make sure we've got some tests that show off what happens to ensure everyone understands what's expected (even if that's "the function is destroyed")

Maybe a couple of tests with e.g. function, symbol etc might be a good idea?

Thank you so much for these suggestions. I missed this part.
I have thought a lot about the most correct solution for this. All the approaches I see now have trade-offs. So, I hope the chosen approach has acceptable trade-offs.
Fix b6e4a5b

@DmitryMakhnev
Copy link
Contributor Author

@SimenB,
I see that the PR has 11 failed checks.
All of them have same failed message https://github.com/jestjs/jest/actions/runs/9995583298/job/27628086141?pr=15191.
Also I see that other last PR have same issue. It looks like the fails were produced by 22.5.0 version of Node.js https://github.com/jestjs/jest/actions/runs/9995583298/job/27628086141?pr=15191#step:3:10.
Last PR with passed Node.js 22 version had 22.4.1 version https://github.com/jestjs/jest/actions/runs/9969386751/job/27546278751?pr=15194#step:3:10.
Could you please tell me what I should do for fixing this?
Thanks.

@SimenB
Copy link
Member

SimenB commented Jul 19, 2024

I cannot reproduce the failure locally, but yarnpkg/berry#6398 is probably it

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.

the tradeoff you made seems very reasonable to me! Thanks so much for working on this 👍

* It's not ideal to lose `function` and `symbol` types,
* but reliability is more important. Additionally,
* information about issues with these types will be available
* in the error message.
Copy link
Member

Choose a reason for hiding this comment

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

what is the error message? can we have some test for this case (if nothing else so we know if the case is somehow supported?)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thank you so much for catching that. I'm too immersed in the reporters context and used the incorrect place for saving this information.
Fix f4bff33

@SimenB
Copy link
Member

SimenB commented Jul 21, 2024

Sorry, just realised this change is only applied to process, not worker threads. Would you mind adding the same there?

process.send([PARENT_MESSAGE_OK, result]);
try {
process.send([PARENT_MESSAGE_OK, result]);
} catch (error: unknown) {
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
} catch (error: unknown) {
} catch (error) {

it's unknown by default

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks.
Fix bdafa91

@DmitryMakhnev
Copy link
Contributor Author

Hello @SimenB,

Sorry, just realised this change is only applied to process, not worker threads. Would you mind adding the same there?

Sorry for missing this. Thank you so much for catching this. Also I added tests worker threads.
Fix 0b2eb63

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.

wonderful, thank you so much for working on this!

e2e/__tests__/nonSerializableStructuresInequality.test.ts Outdated Show resolved Hide resolved
@SimenB SimenB merged commit 5bfcc22 into jestjs:main Jul 23, 2024
7 of 9 checks passed
fewensa added a commit to helix-bridge/helixconf that referenced this pull request Aug 7, 2024
* Check config

* Clean generate code

* Add verbose control

* Change license follow root project

* Add abis

* Copy abis

* Update config, add contracts

* test abi

* test contracts

* clean generate

* Try test check

* check proxy admin

* merge main

* test

* clean taiko

* test proxy admin

* add contract

* format

* format

* add native token check

* test config

* operator test

* test protocol

* test bridge protocol operator

* full test

* fix syntax

* fix syntax

* fix syntax

* split test

* catch all error, related:  jestjs/jest#10577 (comment) jestjs/jest#10577 (comment) jestjs/jest#15191

* test over all code

* reorder rpc

* jest script

* test spec chains

* chains.test

* verify tokens

* merge main

* test repair & bugfix

* token registered info repair

* check protocol fee

* Fix generated test

* Rename names to codes and fix test function

* Fix tests

* not check now

---------

Co-authored-by: xiaoch05 <xiaoch2010@gmail.com>
@SimenB
Copy link
Member

SimenB commented Aug 8, 2024

https://github.com/jestjs/jest/releases/tag/v30.0.0-alpha.6

@DmitryMakhnev DmitryMakhnev deleted the ISSUE-10577-fix-hang-caused-by-failed-assertions-with-circular-values branch August 19, 2024 09:29
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 Sep 19, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
3 participants