has anyone had an issue with JS memory issue? with...
# pact-js
h
has anyone had an issue with JS memory issue? with
pact v3 node 18 slim
container? It kept getting memory issue from 2gb so I had bumped up to 4gb, but still get some issues. I did not face any issue with
pact v2 with node 14 slim
from 2gb memory, all tests are running passed but getting memory error
Copy code
<--- JS stacktrace --->
 
FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory
 1: 0xb65a10 node::Abort() [/usr/local/bin/node]
 2: 0xa761b5 node::FatalError(char const*, char const*) [/usr/local/bin/node]
 3: 0xd5713e v8::Utils::ReportOOMFailure(v8::internal::Isolate*, char const*, bool) [/usr/local/bin/node]
 4: 0xd574b7 v8::internal::V8::FatalProcessOutOfMemory(v8::internal::Isolate*, char const*, bool) [/usr/local/bin/node]
 5: 0xf34545  [/usr/local/bin/node]
 6: 0xf35448 v8::internal::Heap::RecomputeLimits(v8::internal::GarbageCollector) [/usr/local/bin/node]
 7: 0xf45953  [/usr/local/bin/node]
 8: 0xf467c8 v8::internal::Heap::CollectGarbage(v8::internal::AllocationSpace, v8::internal::GarbageCollectionReason, v8::GCCallbackFlags) [/usr/local/bin/node]
 9: 0xf2112e v8::internal::HeapAllocator::AllocateRawWithLightRetrySlowPath(int, v8::internal::AllocationType, v8::internal::AllocationOrigin, v8::internal::AllocationAlignment) [/usr/local/bin/node]
10: 0xf224f7 v8::internal::HeapAllocator::AllocateRawWithRetryOrFailSlowPath(int, v8::internal::AllocationType, v8::internal::AllocationOrigin, v8::internal::AllocationAlignment) [/usr/local/bin/node]
11: 0xf02a40 v8::internal::Factory::AllocateRaw(int, v8::internal::AllocationType, v8::internal::AllocationAlignment) [/usr/local/bin/node]
12: 0xefa4b4 v8::internal::FactoryBase<v8::internal::Factory>::AllocateRawWithImmortalMap(int, v8::internal::AllocationType, v8::internal::Map, v8::internal::AllocationAlignment) [/usr/local/bin/node]
13: 0xefc768 v8::internal::FactoryBase<v8::internal::Factory>::NewRawOneByteString(int, v8::internal::AllocationType) [/usr/local/bin/node]
14: 0xf05d2d v8::internal::Factory::NewStringFromUtf8(v8::base::Vector<char const> const&, v8::internal::AllocationType) [/usr/local/bin/node]
15: 0xd661a3 v8::String::NewFromUtf8(v8::Isolate*, char const*, v8::NewStringType, int) [/usr/local/bin/node]
16: 0xbba616 v8::MaybeLocal<v8::Value> node::ToV8Value<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >(v8::Local<v8::Context>, std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > > const&, v8::Isolate*) [/usr/local/bin/node]
17: 0xc0f4b5  [/usr/local/bin/node]
18: 0xc1597a  [/usr/local/bin/node]
19: 0x167e06f  [/usr/local/bin/node]
Aborted (core dumped)
so I bumped up memory to 4gb but it still sometimes got error
Copy code
spawn ENOMEM
 
      at spawn (node_modules/cross-spawn/index.js:12:24)
      at Spawn.Object.<anonymous>.Spawn.spawnBinary (node_modules/@pact-foundation/pact-core/src/spawn/spawn.ts:46:22)
      at Server.Object.<anonymous>.AbstractService.spawnBinary (node_modules/@pact-foundation/pact-core/src/service.ts:245:18)
      at Server.Object.<anonymous>.AbstractService.start (node_modules/@pact-foundation/pact-core/src/service.ts:165:28)
      at node_modules/@pact-foundation/src/httpPact/index.ts:277:19
      at Pact.Object.<anonymous>.Pact.startServer (node_modules/@pact-foundation/src/httpPact/index.ts:276:12)
      at node_modules/@pact-foundation/src/httpPact/index.ts:94:24
Copy code
The pact mock service wasn't running when verify was called
 
      at Pact.Object.<anonymous>.Pact.verify (node_modules/@pact-foundation/src/httpPact/index.ts:145:9)
      at Object.<anonymous> (node_modules/jest-pact/index.js:26:45)
anyone had same issue?
t
I haven't. Could it be something else taking up the memory during the test, and it just happens that the failure happens during pact's spawn?
h
yeap, not always happening though but most of the time I would say 70~80%
t
I would profile your app and see where the memory is going
h
ok I will try, but weird thing is when I use v2 with node 14 I have never had an issue
t
(If it is pact, we're very sorry)
h
same docker file just node version and pact version changed lol
dont need to sorry haha , just want to check if someone has same issue lol we really want to use providerstate from v3 that is why
btw any tips to get profile memory leak info?
t
You can run node in debugging mode and attach a profiler
I would be surprised if there is a memory leak in pact that is sufficient to cause this problem. I would guess it is something in your test setup or code under test (or possibly a bug in node).
h
yeap Timothy, I am testing v2 with differ node version… lol it is really deal breaker for me now. what is the best way to achieve
providerState
in v2?? any suggestion example?
t
Wait, are you saying you're using the beta? A memory leak is much more possible in the beta, but the stack trace you posted doesn't look like the beta.
For examples of provider state, have a look in the pact-js examples folder in the pact-js repo on GitHub
h
yeap memory leaks from beta lol it is only works in node 18 , https://github.com/pact-foundation/pact-js/issues/888
the reason I want to use v3 beta is, all of ID is randomly generate it from provider, but v2 example looks like consumer already know id will be
1
t
If the result of your profiling says this is pact, please open an issue. It will be important to fix
As far as I am aware, this is the first time such an issue has been reported though
h
yeap , I wonder how others use v3, it seems only works in node18 slim lol
okay, even v2 I got memory issue with node18-slim so I can say it is node issue lol
t
it might not be node, it could be your code, or pact (but I don't think it is pact)
h
I did not get profile but I am doing middle of conversion v2 to v3, and pact was v3 when I tried to run v2 and v3 altogether in jest-pact, it got memory issue, but when I run only v3 it has no issue, I assume maybe v2 v3 combination issue ?
🤔 1
buy anyway it seems all good now 🙂
t
There should be no problem combining the two.
🤔 1
If it's a memory issue, we’ll need the profiling to look into it
h
yeap I will have try profiling later, and let you know
I found the issue, it was from
redis
from client code lol and it makes hang Jest lol thanks for your help Timothy 🙂
actually, it is more like
jest
issue lol, I had checked with node 16 , no issue lol https://github.com/facebook/jest/issues/7874 I think node 18 in Jest having an issue
👍 1