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

esbuild-plugin-meta-url + quickjs-emscripten aborts #164

Closed
exoego opened this issue Feb 8, 2024 · 0 comments · Fixed by #167
Closed

esbuild-plugin-meta-url + quickjs-emscripten aborts #164

exoego opened this issue Feb 8, 2024 · 0 comments · Fixed by #167

Comments

@exoego
Copy link

exoego commented Feb 8, 2024

Background

I am using https://github.com/justjake/quickjs-emscripten with esbuild.
It works fine until quickjs-emscriptedn v0.24.0.

quickjs-emscripten v0.25.0+ started using import.meta.url, something like new URL("emscripten-module.wasm", import.meta.url).href.
Which is, unfortunately, not supported by esbuild yet: evanw/esbuild#795
Some users (including myself) reported it in justjake/quickjs-emscripten#151

I tried esbuild-plugin-meta-url and found an issue.

Repro

I made a repro here: https://github.com/exoego/quickjs-emscripten-esbuild-repro

git clone https://github.com/exoego/quickjs-emscripten-esbuild-repro.git
npm ci
npm run build

Issue

Running esbuild with meta URL plugin aborts due to heap out of memory:

$ node esbuild.mjs src/runtime/lambda.ts dist/reactor-runtime/index.js

<--- Last few GCs --->

[86731:0x160008000]    36402 ms: Scavenge 4030.8 (4121.5) -> 4029.7 (4131.8) MB, 7.17 / 0.00 ms  (average mu = 0.412, current mu = 0.369) allocation failure; 
[86731:0x160008000]    36426 ms: Scavenge 4036.8 (4132.2) -> 4035.2 (4132.4) MB, 9.71 / 0.00 ms  (average mu = 0.412, current mu = 0.369) allocation failure; 
[86731:0x160008000]    36789 ms: Scavenge 4038.0 (4132.7) -> 4037.4 (4153.4) MB, 360.75 / 0.00 ms  (average mu = 0.412, current mu = 0.369) allocation failure; 


<--- JS stacktrace --->

FATAL ERROR: Reached heap limit Allocation failed - JavaScript heap out of memory
 1: 0x100ee6114 node::Abort() [/Users/exoego/.asdf/installs/nodejs/20.9.0/bin/node]
 2: 0x100ee62fc node::ModifyCodeGenerationFromStrings(v8::Local<v8::Context>, v8::Local<v8::Value>, bool) [/Users/exoego/.asdf/installs/nodejs/20.9.0/bin/node]
 3: 0x10106d048 v8::internal::V8::FatalProcessOutOfMemory(v8::internal::Isolate*, char const*, v8::OOMDetails const&) [/Users/exoego/.asdf/installs/nodejs/20.9.0/bin/node]
 4: 0x10124182c v8::internal::Heap::GarbageCollectionReasonToString(v8::internal::GarbageCollectionReason) [/Users/exoego/.asdf/installs/nodejs/20.9.0/bin/node]
 5: 0x101240308 v8::internal::Heap::CollectGarbage(v8::internal::AllocationSpace, v8::internal::GarbageCollectionReason, v8::GCCallbackFlags) [/Users/exoego/.asdf/installs/nodejs/20.9.0/bin/node]
 6: 0x101236b20 v8::internal::HeapAllocator::AllocateRawWithLightRetrySlowPath(int, v8::internal::AllocationType, v8::internal::AllocationOrigin, v8::internal::AllocationAlignment) [/Users/exoego/.asdf/installs/nodejs/20.9.0/bin/node]
 7: 0x101237380 v8::internal::HeapAllocator::AllocateRawWithRetryOrFailSlowPath(int, v8::internal::AllocationType, v8::internal::AllocationOrigin, v8::internal::AllocationAlignment) [/Users/exoego/.asdf/installs/nodejs/20.9.0/bin/node]
 8: 0x10121c384 v8::internal::Factory::NewFillerObject(int, v8::internal::AllocationAlignment, v8::internal::AllocationType, v8::internal::AllocationOrigin) [/Users/exoego/.asdf/installs/nodejs/20.9.0/bin/node]
 9: 0x101603d94 v8::internal::Runtime_AllocateInYoungGeneration(int, unsigned long*, v8::internal::Isolate*) [/Users/exoego/.asdf/installs/nodejs/20.9.0/bin/node]
10: 0x101960c44 Builtins_CEntry_Return1_ArgvOnStack_NoBuiltinExit [/Users/exoego/.asdf/installs/nodejs/20.9.0/bin/node]
11: 0x101909038 Builtins_ArrayPrototypePush [/Users/exoego/.asdf/installs/nodejs/20.9.0/bin/node]
12: 0x106cbb1c0 
13: 0x106cfbcbc 
14: 0x1018d5708 construct_stub_create_deopt_addr [/Users/exoego/.asdf/installs/nodejs/20.9.0/bin/node]
15: 0x106c9c760 
16: 0x106cf1290 
17: 0x106d8cbfc 
18: 0x10190f210 Builtins_AsyncFunctionAwaitResolveClosure [/Users/exoego/.asdf/installs/nodejs/20.9.0/bin/node]
19: 0x1019bcfb8 Builtins_PromiseFulfillReactionJob [/Users/exoego/.asdf/installs/nodejs/20.9.0/bin/node]
20: 0x1018feb94 Builtins_RunMicrotasks [/Users/exoego/.asdf/installs/nodejs/20.9.0/bin/node]
21: 0x1018d63f4 Builtins_JSRunMicrotasksEntry [/Users/exoego/.asdf/installs/nodejs/20.9.0/bin/node]
22: 0x1011aec94 v8::internal::(anonymous namespace)::Invoke(v8::internal::Isolate*, v8::internal::(anonymous namespace)::InvokeParams const&) [/Users/exoego/.asdf/installs/nodejs/20.9.0/bin/node]
23: 0x1011af180 v8::internal::(anonymous namespace)::InvokeWithTryCatch(v8::internal::Isolate*, v8::internal::(anonymous namespace)::InvokeParams const&) [/Users/exoego/.asdf/installs/nodejs/20.9.0/bin/node]
24: 0x1011af35c v8::internal::Execution::TryRunMicrotasks(v8::internal::Isolate*, v8::internal::MicrotaskQueue*) [/Users/exoego/.asdf/installs/nodejs/20.9.0/bin/node]
25: 0x1011d6418 v8::internal::MicrotaskQueue::RunMicrotasks(v8::internal::Isolate*) [/Users/exoego/.asdf/installs/nodejs/20.9.0/bin/node]
26: 0x1011d6bb4 v8::internal::MicrotaskQueue::PerformCheckpoint(v8::Isolate*) [/Users/exoego/.asdf/installs/nodejs/20.9.0/bin/node]
27: 0x100e18c64 node::InternalCallbackScope::Close() [/Users/exoego/.asdf/installs/nodejs/20.9.0/bin/node]
28: 0x100e187c4 node::InternalCallbackScope::~InternalCallbackScope() [/Users/exoego/.asdf/installs/nodejs/20.9.0/bin/node]
29: 0x100eea0fc node::fs::FileHandle::CloseReq::Resolve() [/Users/exoego/.asdf/installs/nodejs/20.9.0/bin/node]
30: 0x100f06018 node::fs::FileHandle::ClosePromise()::$_0::__invoke(uv_fs_s*) [/Users/exoego/.asdf/installs/nodejs/20.9.0/bin/node]
31: 0x100ee1210 node::MakeLibuvRequestCallback<uv_fs_s, void (*)(uv_fs_s*)>::Wrapper(uv_fs_s*) [/Users/exoego/.asdf/installs/nodejs/20.9.0/bin/node]
32: 0x1018b4d4c uv__work_done [/Users/exoego/.asdf/installs/nodejs/20.9.0/bin/node]
33: 0x1018b879c uv__async_io [/Users/exoego/.asdf/installs/nodejs/20.9.0/bin/node]
34: 0x1018ca874 uv__io_poll [/Users/exoego/.asdf/installs/nodejs/20.9.0/bin/node]
35: 0x1018b8d60 uv_run [/Users/exoego/.asdf/installs/nodejs/20.9.0/bin/node]
36: 0x100e19754 node::SpinEventLoopInternal(node::Environment*) [/Users/exoego/.asdf/installs/nodejs/20.9.0/bin/node]
37: 0x100f29138 node::NodeMainInstance::Run(node::ExitCode*, node::Environment*) [/Users/exoego/.asdf/installs/nodejs/20.9.0/bin/node]
38: 0x100f28ed4 node::NodeMainInstance::Run() [/Users/exoego/.asdf/installs/nodejs/20.9.0/bin/node]
39: 0x100eb160c node::Start(int, char**) [/Users/exoego/.asdf/installs/nodejs/20.9.0/bin/node]
40: 0x181a290e0 start [/usr/lib/dyld]

I gave a try on large heap but did not help: node --max-old-space-size=24000 esbuild.mjs which hangs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant