adriantoine / enzyme-to-json

Snapshot test your Enzyme wrappers
MIT License
950 stars 64 forks source link

Node crashes when using toJson #166

Open boatcoder opened 4 years ago

boatcoder commented 4 years ago

I've tried it with v10.18.1, v10.19.0 and 12.16.1 and all of them fail the same way. Not sure what is going on here. This only started once I used toJson, and quits when I don't use it.

enzyme-to-json version: v3.4.4

FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory
 1: 0x100080c68 node::Abort() [/Users/mark/.nvm/versions/node/v12.16.1/bin/node]
 2: 0x100080dec node::errors::TryCatchScope::~TryCatchScope() [/Users/mark/.nvm/versions/node/v12.16.1/bin/node]
 3: 0x100185167 v8::Utils::ReportOOMFailure(v8::internal::Isolate*, char const*, bool) [/Users/mark/.nvm/versions/node/v12.16.1/bin/node]
 4: 0x100185103 v8::internal::V8::FatalProcessOutOfMemory(v8::internal::Isolate*, char const*, bool) [/Users/mark/.nvm/versions/node/v12.16.1/bin/node]
 5: 0x10030b2f5 v8::internal::Heap::FatalProcessOutOfMemory(char const*) [/Users/mark/.nvm/versions/node/v12.16.1/bin/node]
 6: 0x10030c9c4 v8::internal::Heap::RecomputeLimits(v8::internal::GarbageCollector) [/Users/mark/.nvm/versions/node/v12.16.1/bin/node]
 7: 0x100309837 v8::internal::Heap::PerformGarbageCollection(v8::internal::GarbageCollector, v8::GCCallbackFlags) [/Users/mark/.nvm/versions/node/v12.16.1/bin/node]
 8: 0x1003077fd v8::internal::Heap::CollectGarbage(v8::internal::AllocationSpace, v8::internal::GarbageCollectionReason, v8::GCCallbackFlags) [/Users/mark/.nvm/versions/node/v12.16.1/bin/node]
 9: 0x100307cd3 v8::internal::Heap::CollectAllAvailableGarbage(v8::internal::GarbageCollectionReason) [/Users/mark/.nvm/versions/node/v12.16.1/bin/node]
10: 0x1003130a6 v8::internal::Heap::AllocateRawWithRetryOrFail(int, v8::internal::AllocationType, v8::internal::AllocationOrigin, v8::internal::AllocationAlignment) [/Users/mark/.nvm/versions/node/v12.16.1/bin/node]
11: 0x1002e273c v8::internal::Factory::NewRawTwoByteString(int, v8::internal::AllocationType) [/Users/mark/.nvm/versions/node/v12.16.1/bin/node]
12: 0x100690a19 v8::internal::IncrementalStringBuilder::Extend() [/Users/mark/.nvm/versions/node/v12.16.1/bin/node]
13: 0x1004075c6 v8::internal::JsonStringifier::SerializeString(v8::internal::Handle<v8::internal::String>) [/Users/mark/.nvm/versions/node/v12.16.1/bin/node]
14: 0x10040ba4b v8::internal::JsonStringifier::Result v8::internal::JsonStringifier::Serialize_<true>(v8::internal::Handle<v8::internal::Object>, bool, v8::internal::Handle<v8::internal::Object>) [/Users/mark/.nvm/versions/node/v12.16.1/bin/node]
15: 0x10040a393 v8::internal::JsonStringifier::Result v8::internal::JsonStringifier::Serialize_<false>(v8::internal::Handle<v8::internal::Object>, bool, v8::internal::Handle<v8::internal::Object>) [/Users/mark/.nvm/versions/node/v12.16.1/bin/node]
16: 0x100409c04 v8::internal::JsonStringifier::Result v8::internal::JsonStringifier::Serialize_<false>(v8::internal::Handle<v8::internal::Object>, bool, v8::internal::Handle<v8::internal::Object>) [/Users/mark/.nvm/versions/node/v12.16.1/bin/node]
17: 0x100404f2c v8::internal::JsonStringify(v8::internal::Isolate*, v8::internal::Handle<v8::internal::Object>, v8::internal::Handle<v8::internal::Object>, v8::internal::Handle<v8::internal::Object>) [/Users/mark/.nvm/versions/node/v12.16.1/bin/node]
18: 0x10022886a v8::internal::Builtin_JsonStringify(int, unsigned long*, v8::internal::Isolate*) [/Users/mark/.nvm/versions/node/v12.16.1/bin/node]
19: 0x100950a19 Builtins_CEntry_Return1_DontSaveFPRegs_ArgvOnStack_BuiltinExit [/Users/mark/.nvm/versions/node/v12.16.1/bin/node]

<--- Last few GCs --->

[58419:0x10291f000]    31010 ms: Mark-sweep 2007.8 (2079.8) -> 2007.8 (2079.8) MB, 82.0 / 0.0 ms  (average mu = 0.132, current mu = 0.002) allocation failure scavenge might not succeed
[58419:0x10291f000]    31097 ms: Mark-sweep 2007.8 (2079.8) -> 2007.8 (2079.8) MB, 86.6 / 0.0 ms  (average mu = 0.070, current mu = 0.000) allocation failure scavenge might not succeed

<--- JS stacktrace --->

==== JS stack trace =========================================

Security context: 0x1adb17c408d1 <JSObject>
    0: builtin exit frame: stringify(aka stringify)(this=0x1adb657004b1 <undefined>,0x1adb657004b1 <undefined>,0x1adb657004b1 <undefined>,0x1adbbf33d839 <JSArray[2]>,0x1adb657004b1 <undefined>)

    1: arguments adaptor frame: 1->3
    2: writeChannelMessage(aka writeChannelMessage) [0x1adbe4cca081] [internal/child_process/serialization.js:118] [bytecode=0x1adbaa53ec61 offset=7](this=0x1adb65700...
VincentLanglet commented 4 years ago

Did you try others enzyme-to-json version ? @boatcoder

boatcoder commented 4 years ago

3.4.3, same effect.

On Sun, Mar 8, 2020 at 4:34 PM Vincent Langlet notifications@github.com wrote:

Did you try other enzyme-to-json version ? @boatcoder https://github.com/boatcoder

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/adriantoine/enzyme-to-json/issues/166?email_source=notifications&email_token=AENX3UO2OTAKBCT2ODHGYK3RGP6LRA5CNFSM4LDZSX72YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEOFAWGY#issuecomment-596249371, or unsubscribe https://github.com/notifications/unsubscribe-auth/AENX3UM3SEJD7EGRIVH7H2TRGP6LRANCNFSM4LDZSX7Q .

boatcoder commented 4 years ago

Also tried it on linux (in a docker) and it crashed the same way

On Mon, Mar 9, 2020 at 8:30 PM Mark Jones boatcoder@gmail.com wrote:

3.4.3, same effect.

On Sun, Mar 8, 2020 at 4:34 PM Vincent Langlet notifications@github.com wrote:

Did you try other enzyme-to-json version ? @boatcoder https://github.com/boatcoder

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/adriantoine/enzyme-to-json/issues/166?email_source=notifications&email_token=AENX3UO2OTAKBCT2ODHGYK3RGP6LRA5CNFSM4LDZSX72YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEOFAWGY#issuecomment-596249371, or unsubscribe https://github.com/notifications/unsubscribe-auth/AENX3UM3SEJD7EGRIVH7H2TRGP6LRANCNFSM4LDZSX7Q .

VincentLanglet commented 4 years ago

I'm using this on node 12 without any issue...

Any ideas @adriantoine ?

adriantoine commented 4 years ago

Hi,

It doesn't seem to be related to this library, did you have any issues using any other node libraries? Did you try to run your tests without enzyme-to-json? Also can you provide the complete test case to reproduce the issue?

Thanks!

boatcoder commented 4 years ago

The only change I need to make to the project is to add enzyme-to-json. Removing it removes the crash. I'm using storybook as well which has it's own snapshot serializer that does not cause the problem. I'll try to make some kind of minimal case after friday this week. Got a deadline to get done

On Mon, Mar 9, 2020 at 11:32 PM Adrien Antoine notifications@github.com wrote:

Hi,

It doesn't seem to be related to this library, did you have any issues using any other node libraries? Did you try to run your tests without enzyme-to-json? Also can you provide the complete test case to reproduce the issue?

Thanks!

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/adriantoine/enzyme-to-json/issues/166?email_source=notifications&email_token=AENX3UP7WPLYXQ7QEF3BOJLRGWYFRA5CNFSM4LDZSX72YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEOJ3W3I#issuecomment-596884333, or unsubscribe https://github.com/notifications/unsubscribe-auth/AENX3ULXREJ2TESJ3NK47ALRGWYFRANCNFSM4LDZSX7Q .

20BBrown14 commented 4 years ago

I'm getting a very similar issue when mounting a component for snapshot testing. Tried enzyme 3.4.4 and 3.5.0 with Jest 24, 25, and 26. Tried it with using the helper toJson and with jest's snapshotSerializer config. Also tried with Node lts/dubnium and Node lts/erbium Was also able to reproduce the issue with the same config on a different machine and OS.

Repo is here: https://github.com/20BBrown14/digital-terrain-mc-js/tree/feature/add_layout

Offending test is tests/components/header/HeaderView.test.jsx