-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
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
Node crashes with OOM if you pass pretty-format a large object #7380
Comments
"sufficiently large object" is tracked in #1772. However, @rickhanlonii @pedrottimark agree? |
Yeah that makes sense to me 👍 |
We have added special cases for real use cases related to It seems like
|
Consider this a request to support it, then 😀
Seeing as serialization is synchronous, I don't think so. Unless we spin up a separate But maybe we can abort if the string we are creating is getting bigger than, say, 5000 chars? Or depth passes 15? |
@theneva Here are questions to select from possible changes to improve developer experience:
|
Hi! Sorry about the delay on this… Yeah, To be honest, I've never had a case of objects that are too big for serialisation except when I accidentally expected From a slightly ivory tower-y standpoint, though, I think it makes sense for every utility that comes out of the box with Jest (such as matchers) to honour the test timeouts if possible. I took a quick look at
If you don't see anything obviously wrong with that approach, I would be happy to try my hand at it. @SimenB I agree that aborting on a max value for string length or object depth would be much better than the current behaviour, but I think it would be really hard to find a good max value: 100k character snapshots are a real use case—for example, a slightly complex GraphQL schema parsed with @pedrottimark I'm not entirely sure what you're asking. Please elaborate? 😄 |
We've shipped a new diffing algorithm in Jest 24, so I think we can close this. Might revisit some upper bound on diff size if it's still an issue |
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
🐛 Bug Report
Node runs out of heap space and aborts with stack trace from V8 if you pass a large enough object to
pretty-format
, for example viatoMatch[Inline]Snapshot()
.I suppose this ties in with #4645, although that was closed by forcing
pretty-format
to not serialise the object type in question as a regular object.To Reproduce
Assuming you run in the default
jest-environment-jsdom
,document
is all you need to provoke this behaviour:Expected behavior
I think
pretty-format
should fail the test with an informative message instead of letting the Jest/Node process die if the serialisation is about to fill the heap.One way to do this could be to abort object serialisation when when the test would otherwise time out. It takes (much) longer than the default test timeout of 5 seconds to run out of memory on my late 2013 MacBook Pro:
Link to repl or repo (highly encouraged)
See screenshot and repro using that test here: https://github.com/theneva/jest-expect-document
Run
npx envinfo --preset jest
Paste the results here:
The text was updated successfully, but these errors were encountered: