danielwaltz / vite-plugin-graphql-codegen

Zero-config vite plugin that uses the vite file watcher to run graphql codegen programmatically without needing to start a separate watcher
https://www.npmjs.com/package/vite-plugin-graphql-codegen
MIT License
83 stars 8 forks source link

Heap out of memory after many hours #27

Open deathemperor opened 11 months ago

deathemperor commented 11 months ago

Running vite for many hours (within a workday) causes heap out of memory

<--- Last few GCs --->

[57364:0x138040000] 19512444 ms: Mark-sweep 4036.0 (4139.3) -> 4030.6 (4142.6) MB, 737.7 / 0.0 ms  (average mu = 0.461, current mu = 0.052) allocation failure; scavenge might not succeed
[57364:0x138040000] 19513801 ms: Mark-sweep 4040.6 (4144.0) -> 4035.3 (4147.0) MB, 1341.2 / 0.0 ms  (average mu = 0.226, current mu = 0.011) allocation failure; scavenge might not succeed

<--- JS stacktrace --->

FATAL ERROR: Reached heap limit Allocation failed - JavaScript heap out of memory

 1: 0x1007b3c40 node::Abort() [/Users/deathemperor/.nvm/versions/node/v18.18.2/bin/node]
 2: 0x1007b3e24 node::ModifyCodeGenerationFromStrings(v8::Local<v8::Context>, v8::Local<v8::Value>, bool) [/Users/deathemperor/.nvm/versions/node/v18.18.2/bin/node]

 3: 0x10090b608 v8::internal::V8::FatalProcessOutOfMemory(v8::internal::Isolate*, char const*, bool) [/Users/deathemperor/.nvm/versions/node/v18.18.2/bin/node]

 4: 0x100ab5eec v8::internal::EmbedderStackStateScope::EmbedderStackStateScope(v8::internal::Heap*, v8::internal::EmbedderStackStateScope::Origin, cppgc::EmbedderStackState) [/Users/deathemperor/.nvm/versions/node/v18.18.2/bin/node]

 5: 0x100ab4894 v8::internal::Heap::CollectGarbage(v8::internal::AllocationSpace, v8::internal::GarbageCollectionReason, v8::GCCallbackFlags) [/Users/deathemperor/.nvm/versions/node/v18.18.2/bin/node]

 6: 0x100aa8928 v8::internal::HeapAllocator::AllocateRawWithLightRetrySlowPath(int, v8::internal::AllocationType, v8::internal::AllocationOrigin, v8::internal::AllocationAlignment) [/Users/deathemperor/.nvm/versions/node/v18.18.2/bin/node]

 7: 0x100aa916c v8::internal::HeapAllocator::AllocateRawWithRetryOrFailSlowPath(int, v8::internal::AllocationType, v8::internal::AllocationOrigin, v8::internal::AllocationAlignment) [/Users/deathemperor/.nvm/versions/node/v18.18.2/bin/node]

 8: 0x100a8f0ec v8::internal::Factory::NewFillerObject(int, v8::internal::AllocationAlignment, v8::internal::AllocationType, v8::internal::AllocationOrigin) [/Users/deathemperor/.nvm/versions/node/v18.18.2/bin/node]

 9: 0x100e2f80c v8::internal::Runtime_AllocateInYoungGeneration(int, unsigned long*, v8::internal::Isolate*) [/Users/deathemperor/.nvm/versions/node/v18.18.2/bin/node]

10: 0x10117d04c Builtins_CEntry_Return1_DontSaveFPRegs_ArgvOnStack_NoBuiltinExit [/Users/deathemperor/.nvm/versions/node/v18.18.2/bin/node]

11: 0x10114ee30 Builtins_CloneObjectIC [/Users/deathemperor/.nvm/versions/node/v18.18.2/bin/node]

12: 0x10698bb68 

13: 0x101108198 Builtins_InterpreterEntryTrampoline [/Users/deathemperor/.nvm/versions/node/v18.18.2/bin/node]

14: 0x101108198 Builtins_InterpreterEntryTrampoline [/Users/deathemperor/.nvm/versions/node/v18.18.2/bin/node]

15: 0x101108198 Builtins_InterpreterEntryTrampoline [/Users/deathemperor/.nvm/versions/node/v18.18.2/bin/node]

16: 0x101108198 Builtins_InterpreterEntryTrampoline [/Users/deathemperor/.nvm/versions/node/v18.18.2/bin/node]

17: 0x101108198 Builtins_InterpreterEntryTrampoline [/Users/deathemperor/.nvm/versions/node/v18.18.2/bin/node]
18: 0x1068e0b38 

19: 0x101139ef4 Builtins_AsyncFunctionAwaitResolveClosure [/Users/deathemperor/.nvm/versions/node/v18.18.2/bin/node]

20: 0x1011c8738 Builtins_PromiseFulfillReactionJob [/Users/deathemperor/.nvm/versions/node/v18.18.2/bin/node]

21: 0x10112bc4c Builtins_RunMicrotasks [/Users/deathemperor/.nvm/versions/node/v18.18.2/bin/node]

22: 0x1011063a4 Builtins_JSRunMicrotasksEntry [/Users/deathemperor/.nvm/versions/node/v18.18.2/bin/node]

23: 0x100a37d38 v8::internal::(anonymous namespace)::Invoke(v8::internal::Isolate*, v8::internal::(anonymous namespace)::InvokeParams const&) [/Users/deathemperor/.nvm/versions/node/v18.18.2/bin/node]

24: 0x100a38228 v8::internal::(anonymous namespace)::InvokeWithTryCatch(v8::internal::Isolate*, v8::internal::(anonymous namespace)::InvokeParams const&) [/Users/deathemperor/.nvm/versions/node/v18.18.2/bin/node]

25: 0x100a38404 v8::internal::Execution::TryRunMicrotasks(v8::internal::Isolate*, v8::internal::MicrotaskQueue*, v8::internal::MaybeHandle<v8::internal::Object>*) [/Users/deathemperor/.nvm/versions/node/v18.18.2/bin/node]

26: 0x100a5eb6c v8::internal::MicrotaskQueue::RunMicrotasks(v8::internal::Isolate*) [/Users/deathemperor/.nvm/versions/node/v18.18.2/bin/node]

27: 0x100a5f308 v8::internal::MicrotaskQueue::PerformCheckpoint(v8::Isolate*) [/Users/deathemperor/.nvm/versions/node/v18.18.2/bin/node]

28: 0x1006f8c4c node::InternalCallbackScope::Close() [/Users/deathemperor/.nvm/versions/node/v18.18.2/bin/node]

29: 0x1006f87c4 node::InternalCallbackScope::~InternalCallbackScope() [/Users/deathemperor/.nvm/versions/node/v18.18.2/bin/node]

30: 0x1007b7464 node::fs::FileHandle::CloseReq::Resolve() [/Users/deathemperor/.nvm/versions/node/v18.18.2/bin/node]

31: 0x1007cdef8 node::fs::FileHandle::ClosePromise()::$_0::__invoke(uv_fs_s*) [/Users/deathemperor/.nvm/versions/node/v18.18.2/bin/node]

32: 0x1007afbb0 node::MakeLibuvRequestCallback<uv_fs_s, void (*)(uv_fs_s*)>::Wrapper(uv_fs_s*) [/Users/deathemperor/.nvm/versions/node/v18.18.2/bin/node]

33: 0x1010e42e8 uv__work_done [/Users/deathemperor/.nvm/versions/node/v18.18.2/bin/node]

34: 0x1010e7aa4 uv__async_io [/Users/deathemperor/.nvm/versions/node/v18.18.2/bin/node]

35: 0x1010fa058 uv__io_poll [/Users/deathemperor/.nvm/versions/node/v18.18.2/bin/node]

36: 0x1010e7f74 uv_run [/Users/deathemperor/.nvm/versions/node/v18.18.2/bin/node]

37: 0x1006f96e0 node::SpinEventLoop(node::Environment*) [/Users/deathemperor/.nvm/versions/node/v18.18.2/bin/node]

38: 0x1007f0850 node::NodeMainInstance::Run() [/Users/deathemperor/.nvm/versions/node/v18.18.2/bin/node]

39: 0x1007806a4 node::LoadSnapshotDataAndRun(node::SnapshotData const**, node::InitializationResult const*) [/Users/deathemperor/.nvm/versions/node/v18.18.2/bin/node]

40: 0x10078095c node::Start(int, char**) [/Users/deathemperor/.nvm/versions/node/v18.18.2/bin/node]
41: 0x184a010e0 start [/usr/lib/dyld]

error: "vite" exited with code 6 (SIGABRT)
danielwaltz commented 10 months ago

Do you feel like maybe this is related to this plugin? Looking at the output here I think it's hard to say what the source of the memory leak is. I would be inclined to think because the surface area of this plugin is relatively small compared to Vite and GraphQL Codegen (and this is just some glue between them) that it may be something to do with them.

That said, if you have any more insight that might help provide a clue or hint at it being this plugin I'm open to investigate!

deathemperor commented 10 months ago

I have no ideas how these memory issues are and they are normally not easy to investigate. I'm more on running vite with bun but as of today this https://github.com/oven-sh/bun/issues/887 prevents it. will have to wait.