You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Using custom loaders results in a load loop / OOM #47566
How often does it reproduce? Is there a required condition?
No response
What is the expected behavior? Why is that the expected behavior?
Node.js starts up without loading the provided loader over and over again.
What do you see instead?
Node.js spams the console with the following warning while the memory and CPU usage climbs until it's stopped / OOMs.
(node:5652) ExperimentalWarning: Custom ESM Loaders is an experimental feature and might change at any time
(Use `node --trace-warnings ...` to show where the warning was created)
changed the title [-]Combining `--require` and `--loader` results in a load loop[/-][+]Combining `--require` and `--loader` results in a load loop / OOM[/+]on Apr 14, 2023
I'm able to reproduce with the suggested code snippet, but it looks like there's more to it than just combining --require and --loader, here's what I get when running the following at the root of the node repo:
changed the title [-]Combining `--require` and `--loader` results in a load loop / OOM[/-][+]Using custom loaders results in a load loop / OOM[/+]on Apr 17, 2023
I think this is happening because the loader is going to try to spawn a worker thread from within the worker thread, which is also going to do the same thing, and that's how we end up with Mr Meeseeks situation until the system is out of memory or the process terminates. I'm working on a fix.
I'd note that some systems like ServiceWorkers / SharedWorkers avoid this
by having a shared cache based upon URL of the entrypoint. That would also
reduce overall burden.
On Mon, Apr 17, 2023 at 1:33 PM Antoine du Hamel ***@***.***> wrote:
I think this is happening because the loader is going to try to spawn a
worker thread from within the worker thread, which is also going to do the
same thing, and that's how we end up with Mr Meeseeks situation until the
system is out of memory or the process terminates. I'm working on a fix.
—
Reply to this email directly, view it on GitHub
<#47566 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AABZJI4ZGXW3P53XYIGMCPDXBWEHBANCNFSM6AAAAAAW66HUD4>
.
You are receiving this because you are on a team that was mentioned.Message
ID: ***@***.***>
// works
import { get } from 'node:https';
// both do not work and restart the loader in a loop
import CoffeeScript from 'coffeescript';
import mysql from 'mysql';
(node:9286) ExperimentalWarning: Custom ESM Loaders is an experimental feature and might change at any time
(Use node --trace-warnings ... to show where the warning was created)
(node:9286) ExperimentalWarning: Custom ESM Loaders is an experimental feature and might change at any time
(Use node --trace-warnings ... to show where the warning was created)
(node:9286) ExperimentalWarning: Custom ESM Loaders is an experimental feature and might change at any time
(Use node --trace-warnings ... to show where the warning was created)
(node:9286) ExperimentalWarning: Custom ESM Loaders is an experimental feature and might change at any time
(Use node --trace-warnings ... to show where the warning was created)
Activity
[-]Combining `--require` and `--loader` results in a load loop[/-][+]Combining `--require` and `--loader` results in a load loop / OOM[/+]aduh95 commentedon Apr 15, 2023
@nodejs/loaders
aduh95 commentedon Apr 17, 2023
I'm able to reproduce with the suggested code snippet, but it looks like there's more to it than just combining
--requireand--loader, here's what I get when running the following at the root of the node repo:It looks like the reported bug only happens on REPL. Worth noting that we also another bug that makes the
--required script run twice instead of once.merceyz commentedon Apr 17, 2023
I can also reproduce the issue without the REPL:
aduh95 commentedon Apr 17, 2023
I don't think it has much to do with
--require:[-]Combining `--require` and `--loader` results in a load loop / OOM[/-][+]Using custom loaders results in a load loop / OOM[/+]merceyz commentedon Apr 17, 2023
Indeed, I've updated the issue to reflect that 👍
That's expected behaviour in my opinion, once in the main process and once in the Worker for the loaders.
JakobJingleheimer commentedon Apr 17, 2023
I can't repro at all (admittedly on macOS ARM, but I don't see how this could be OS-related):
At
main's current HEAD (e050cec), the OP'ssnippet
runs endlessly (as expected) and memory stays constant (at 20.2 MB, after start-up), with only 1 experimental warning.
I get the same behaviour on v20.0.0-proposal's current HEAD (bb533f7), but with slightly less memory consumption (20.1 MB after start-up).
The code that controls whether the warning is emitted is quite simple and handles multiple instances of the module loader:
node/lib/internal/modules/esm/loader.js
Lines 405 to 420 in b342a1b
(
emittedExperimentalWarninglives at the top level of esm/loader.js)Am I missing something?
aduh95 commentedon Apr 17, 2023
I think this is happening because the loader is going to try to spawn a worker thread from within the worker thread, which is also going to do the same thing, and that's how we end up with Mr Meeseeks situation until the system is out of memory or the process terminates. I'm working on a fix.
bmeck commentedon Apr 17, 2023
kirrg001 commentedon Apr 19, 2023
Experiencing the same. The loader is loaded over and over again as soon as I import specific libraries.
esm-loader.mjs
Works fine with Node v18
12 remaining items
loader: use default loader as cascaded loader in the in loader worker
TomasHubelbauer commentedon May 4, 2023
FYI 20.1.0 is out and the PR for this issue, #47620, is included in it.
aheissenberger commentedon May 5, 2023
I tested with node 20.1.0 and the problem still exists without any changes:
cyco130/vavite#39 (comment)
TomasHubelbauer commentedon May 5, 2023
Just in case this is useful to anyone - in my case it actually did fix the issue… But it also revealed another one which I think is related: #47880.
kirrg001 commentedon May 8, 2023
Thank you. 20.1.0 fixed the issue for us.
loader: use default loader as cascaded loader in the in loader worker
loader: use default loader as cascaded loader in the in loader worker
loader: use default loader as cascaded loader in the in
loader: use default loader as cascaded loader in the in
fix(loader): avoid Node 20.0 loader recursion
fix(loader): avoid Node 20.0 loader recursion (#9632)
fix(loader): avoid Node 20.0 loader recursion (#9632)
fix(loader): avoid Node 20.0 loader recursion (#9632)
fix(loader): avoid Node 20.0 loader recursion (#9632)
fix(loader): avoid Node 20.0 loader recursion (#9632)