Open markb-trustifi opened 2 years ago
@nodejs/modules
This may also be related to https://github.com/nodejs/node/issues/40201 for the Wasm execution of cjs-module-lexer. One easy fix might be to switch to a JS implementation instead of Wasm, as es-module-lexer does have a JS alternative.
One easy fix might be to switch to a JS implementation instead of Wasm, as es-module-lexer does have a JS alternative.
Yes, but wouldn’t that entail a performance hit? I thought the reason es-module-lexer was written in Wasm was because it ran faster.
I feel like this is a naïve suggestion, but I don’t suppose we could be like “when available memory is below X, use the js es-module-lexer, else use the wasm es-module-lexer.” But then we’re shipping two versions and would need to ensure they stay in sync and always return the same results for the same input.
The performance of the asm.js build of es-module-lexer turned out to be pretty good - https://github.com/guybedford/es-module-lexer/pull/86. A similar build for cjs-module-lexer could be possible.
I retested this issue now on Node.js versions 16.17 and 18.9 with latest Heroku stack 22 and it is still failing.
Apropos this:
node --expose-gc --optimize_for_size --max_old_space_size=9200 main.js
9200 MB doesn't make sense if the instance only has 512 MB available. What happens when you set it 256 or 128?
Version
16.13.2
Platform
Darwin MacBook-Pro.local 20.6.0 Darwin Kernel Version 20.6.0: Wed Nov 10 22:23:07 PST 2021; root:xnu-7195.141.14~1/RELEASE_X86_64 x86_64
Subsystem
No response
What steps will reproduce the bug?
Parent process:
Child forked process:
When project's
package.json
is configured to use the newimports
instead of the oldrequires
("type": "module") the forked process fails with SIGABRT error. It fails only on Heroku Standard X1 env (512Mb) and runs well on X2 env (1Gb). The main process runs with parameters:node --expose-gc --optimize_for_size --max_old_space_size=9200 main.js
How often does it reproduce? Is there a required condition?
The
import
forks fail on Heroku smallest 512Mb envs.What is the expected behavior?
The child forks with
imports
should run on the same env as withrequires
.What do you see instead?
The child forked process starts to load:
...and suddenly fails with SIGABRT.
When the main process runs on a bigger env with 1Gb of memory it loads child process successfully:
When the main process runs with the old-fashion
require
config it runs forks well even on the 512Mb env:Additional information
Please confirm if
import
projects have higher memory requirements than therequire
projects.