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

Move ESM loaders off-thread #44710

Merged
merged 126 commits into from
Apr 13, 2023

Conversation

JakobJingleheimer
Copy link
Contributor

@JakobJingleheimer JakobJingleheimer commented Sep 18, 2022

Resolves #43658

To-dos:

  • Address Module serialisation issue (Proxies aren’t serialisable)
  • Spawn hooks worker only when custom hooks are supplied
  • Convert ESM defaultResolve to synchronous (no real change there)
  • Convert import.meta.resolve() to synchronous
    • When no custom hooks are supplied, just regular sync
    • When any custom hooks are supplied, leverage worker + atomics to simulate sync
  • Handle very large request/response payload (main ↔︎ worker)

Notable changes:

Custom ESM loader hooks run on dedicated thread

ESM hooks supplied via loaders (--experimental-loader=./foo.mjs) now run in a dedicated thread, isolated from the main thread. This provides a separate scope for loaders and ensures no cross-contamination between loaders and application code. A few things to know:

  • Communication between application code and loaders code must now be done via the globalPreload hook’s port. Global variables are not shared between scopes.
  • The dedicated worker thread is spun up only when at least one custom loader is provided.
  • There is an overhead cost to spinning up this thread, increasing both startup time and memory consumption. These are non-trivial, but likely not burdensome.

Synchronous import.meta.resolve()

In alignment with browser behavior, this function now returns synchronously. Despite this, user loader resolve hooks can still be defined as async functions (or as sync functions, if the author prefers). Even when there are async resolve hooks loaded, import.meta.resolve will still return synchronously for application code.

Contributed by Anna Henningsen, Antoine du Hamel, Geoffrey Booth, Guy Bedford, Jacob Smith, and Michaël Zasso in #44710

@nodejs-github-bot
Copy link
Collaborator

Review requested:

  • @nodejs/modules

@nodejs-github-bot nodejs-github-bot added lib / src Issues and PRs related to general changes in the lib or src directory. needs-ci PRs that need a full CI run. labels Sep 18, 2022
lib/internal/modules/esm/public_loader_proxy.js Outdated Show resolved Hide resolved
lib/internal/modules/esm/public_loader_proxy.js Outdated Show resolved Hide resolved
lib/internal/modules/esm/public_loader_proxy.js Outdated Show resolved Hide resolved
lib/internal/modules/esm/public_loader_proxy.js Outdated Show resolved Hide resolved
lib/internal/modules/esm/public_loader_proxy.js Outdated Show resolved Hide resolved
lib/internal/modules/esm/public_loader_proxy.js Outdated Show resolved Hide resolved
lib/internal/modules/esm/public_loader_proxy.js Outdated Show resolved Hide resolved
lib/internal/modules/esm/worker.js Outdated Show resolved Hide resolved
lib/internal/modules/esm/worker.js Outdated Show resolved Hide resolved
lib/internal/process/esm_loader.js Outdated Show resolved Hide resolved
@GeoffreyBooth GeoffreyBooth added esm Issues and PRs related to the ECMAScript Modules implementation. loaders Issues and PRs related to ES module loaders labels Sep 18, 2022
@JakobJingleheimer JakobJingleheimer force-pushed the feat/esm_off-thread-loaders branch 3 times, most recently from 2265b79 to ce94ba6 Compare September 19, 2022 21:17
lib/internal/modules/esm/public_loader_proxy.js Outdated Show resolved Hide resolved
lib/internal/modules/esm/public_loader_proxy.js Outdated Show resolved Hide resolved
lib/internal/modules/esm/worker.js Outdated Show resolved Hide resolved
lib/internal/modules/esm/public_loader_proxy.js Outdated Show resolved Hide resolved
lib/internal/modules/esm/worker.js Outdated Show resolved Hide resolved
lib/internal/modules/esm/worker.js Outdated Show resolved Hide resolved
lib/internal/worker.js Outdated Show resolved Hide resolved
@cspotcode
Copy link

Does each worker thread get its own loader thread? E.g. if an app launches 2x worker threads, there will be 6x threads total: one main, 2x worker, 3x loader?

@JakobJingleheimer
Copy link
Contributor Author

The current design puts all loaders in the same worker thread (eg there are a total of 2 threads: the main and the worker). Internal things are handled via the main thread; userland things are handled by the worker thread.

@cspotcode
Copy link

I think that's slightly different than what I'm asking about. If a node app uses the worker threads API to launch worker threads, does each get its own loader thread? (where each loader thread may have one or more loaders running within it)

Not does each loader get a thread, but does each user thread get a loader thread.

@GeoffreyBooth
Copy link
Member

If a node app uses the worker threads API to launch worker threads, does each get its own loader thread?

I think the current state (before this PR) is that loaders always execute in the main thread, even if they’re “for” user code that is in a worker thread. So I would think that after this PR, loaders would run inside their worker thread, regardless of whether they’re customizing main or worker thread user code.

So in other words, for an app using custom loaders where user code that spawns three workers, there are five threads total: main, loaders, and the three workers spawned by the user code.

This is just my guess, others can please correct me if I’m mistaken.

@targos
Copy link
Member

targos commented Sep 27, 2022

I don't know how it's implemented but I would expect that each Node.js thread (main and workers) has its own separate loaders thread, at least for two reasons:

  • Worker threads are supposed to be as isolated as possible from the main thread and from each other
  • You can spawn a worker thread with a different set of --loader flags.

@bmeck
Copy link
Member

bmeck commented Sep 27, 2022 via email

@targos
Copy link
Member

targos commented Oct 8, 2022

What remains to be done?

@JakobJingleheimer
Copy link
Contributor Author

Something in this implementation is causing node to hang on startup. We suspect it's some kind of circular dependency, and the subsequent dependency smacks into the Atomics lock (preventing the rest of the flow to complete, which would release the initial lock). I think this circular dep is between ESMLoader and Worker (it's rather difficult to troubleshoot as output is swallowed).

There is a working PoC, so we know this works in principle (and that the Atomics otherwise behave appropriately, so the problem lies with integrating it into node).

This was on hold whilst I was on holiday. I'm working on it today and tomorrow (but will be away on a business trip next week).

@JakobJingleheimer
Copy link
Contributor Author

I found the circular dep:

process/esm_loader.js:12modules/esm/public_loader_proxy.js:3worker_thread.js:29/36process/pre_execution.js:562process/esm_loader.js

@JakobJingleheimer
Copy link
Contributor Author

JakobJingleheimer commented Oct 9, 2022

Gah, it wasn't a circular dependency 🤦‍♂️ it was setting url to null here:

node/lib/internal/worker.js

Lines 141 to 149 in 9836c67

if (options.eval || isInternal) {
if (typeof filename !== 'string') {
throw new ERR_INVALID_ARG_VALUE(
'options.eval',
options.eval,
'must be false when \'filename\' is not a string'
);
}
url = null;

which caused the worker to spawn with nothing in it.

(I shouldn't have copied it over from the previous attempt at off-threading, which was later hard-coding the url).

I'm not sure if the internal worker should go through the classic path, or merely get require()ed (I tried both, and it doesn't seem to make a difference).

There is (now was) a circular dependency issue after the empty worker issue is addressed in

initializeESMLoader();

that's now fixed too.

NODE_DEBUG=esm,worker ./out/Release/node -p 1 still doesn't print 1, BUT it does now print debugging output, and we can see it getting fairly far along now, so progress:

ESM 13018: hooking up public ESMLoader
ESM 13018: creating worker for publicESMLoader
[…]
WORKER 15812: instantiating Worker. url: file:///…/nodejs/node/lib/internal/modules/esm/worker.js doEval: classic
WORKER 15812: [0] created Worker with ID 1

esm/worker.js's debug (worker for public ESM running) is not printing, so that's likely why things have stalled (as soon as the worker is running, it releases the lock).

RafaelGSS added a commit that referenced this pull request Apr 14, 2023
Notable Changes:

crypto:
  * (SEMVER-MAJOR) use WebIDL converters in WebCryptoAPI (Filip Skokan) #46067
deps:
  * update ada to 2.0.0 (Node.js GitHub Bot) #47339
esm:
  * move hook execution to separate thread (Jacob Smith) #44710
sea:
  * use JSON configuration and blob content for SEA (Joyee Cheung) #47125
src,process:
  * (SEMVER-MINOR) add permission model (Rafael Gonzaga) #44004
url:
  * drop ICU requirement for parsing hostnames (Yagiz Nizipli) #47339
  * use ada::url_aggregator for parsing urls (Yagiz Nizipli) #47339
  * (SEMVER-MAJOR) runtime-deprecate url.parse() with invalid ports (Rich Trott) #45526

Semver-Major Commits:

* [9fafb0a] - (SEMVER-MAJOR) async_hooks: deprecate the AsyncResource.bind asyncResource property (James M Snell) #46432
* [1948d37] - (SEMVER-MAJOR) buffer: check INSPECT_MAX_BYTES with validateNumber (Umuoy) #46599
* [7bc0e6a] - (SEMVER-MAJOR) buffer: graduate File from experimental and expose as global (Khafra) #47153
* [671ffd7] - (SEMVER-MAJOR) buffer: use min/max of `validateNumber` (Deokjin Kim) #45796
* [ab1614d] - (SEMVER-MAJOR) build: reset embedder string to "-node.0" (Michaël Zasso) #47251
* [c1bcdbc] - (SEMVER-MAJOR) build: warn for gcc versions earlier than 10.1 (Richard Lau) #46806
* [649f68f] - (SEMVER-MAJOR) build: reset embedder string to "-node.0" (Yagiz Nizipli) #45579
* [9374700] - (SEMVER-MAJOR) crypto: remove DEFAULT_ENCODING (Tobias Nießen) #47182
* [1640aeb] - (SEMVER-MAJOR) crypto: remove obsolete SSL_OP_* constants (Tobias Nießen) #47073
* [c2e4b1f] - (SEMVER-MAJOR) crypto: remove ALPN_ENABLED (Tobias Nießen) #47028
* [3ef38c4] - (SEMVER-MAJOR) crypto: use WebIDL converters in WebCryptoAPI (Filip Skokan) #46067
* [08af023] - (SEMVER-MAJOR) crypto: runtime deprecate replaced rsa-pss keygen parameters (Filip Skokan) #45653
* [7eb0ac3] - (SEMVER-MAJOR) deps: patch V8 to support compilation on win-arm64 (Michaël Zasso) #47251
* [a7c129f] - (SEMVER-MAJOR) deps: silence irrelevant V8 warning (Michaël Zasso) #47251
* [6f5655a] - (SEMVER-MAJOR) deps: always define V8_EXPORT_PRIVATE as no-op (Michaël Zasso) #47251
* [f226350] - (SEMVER-MAJOR) deps: update V8 to 11.3.244.4 (Michaël Zasso) #47251
* [d6dae74] - (SEMVER-MAJOR) deps: V8: cherry-pick f1c888e7093e (Michaël Zasso) #45579
* [56c4365] - (SEMVER-MAJOR) deps: fix V8 build on Windows with MSVC (Michaël Zasso) #45579
* [51ab98c] - (SEMVER-MAJOR) deps: silence irrelevant V8 warning (Michaël Zasso) #45579
* [9f84d3e] - (SEMVER-MAJOR) deps: V8: fix v8-cppgc.h for MSVC (Jiawen Geng) #45579
* [f2318cd] - (SEMVER-MAJOR) deps: fix V8 build issue with inline methods (Jiawen Geng) #45579
* [16e03e7] - (SEMVER-MAJOR) deps: update V8 to 10.9.194.4 (Yagiz Nizipli) #45579
* [6473f5e] - (SEMVER-MAJOR) doc: update toolchains used for Node.js 20 releases (Richard Lau) #47352
* [cc18fd9] - (SEMVER-MAJOR) events: refactor to use `validateNumber` (Deokjin Kim) #45770
* [ff92b40] - (SEMVER-MAJOR) http: close the connection after sending a body without declared length (Tim Perry) #46333
* [2a29df6] - (SEMVER-MAJOR) http: keep HTTP/1.1 conns alive even if the Connection header is removed (Tim Perry) #46331
* [391dc74] - (SEMVER-MAJOR) http: throw error if options of http.Server is array (Deokjin Kim) #46283
* [ed3604c] - (SEMVER-MAJOR) http: server check Host header, to meet RFC 7230 5.4 requirement (wwwzbwcom) #45597
* [88d71dc] - (SEMVER-MAJOR) lib: refactor to use min/max of `validateNumber` (Deokjin Kim) #45772
* [e4d641f] - (SEMVER-MAJOR) lib: refactor to use validators in http2 (Debadree Chatterjee) #46174
* [0f3e531] - (SEMVER-MAJOR) lib: performance improvement on readline async iterator (Thiago Oliveira Santos) #41276
* [5b5898a] - (SEMVER-MAJOR) lib,src: update exit codes as per todos (Debadree Chatterjee) #45841
* [55321ba] - (SEMVER-MAJOR) net: enable autoSelectFamily by default (Paolo Insogna) #46790
* [2d0d997] - (SEMVER-MAJOR) process: remove `process.exit()`, `process.exitCode` coercion to integer (Daeyeon Jeong) #43716
* [dc06df3] - (SEMVER-MAJOR) readline: refactor to use `validateNumber` (Deokjin Kim) #45801
* [295b2f3] - (SEMVER-MAJOR) src: update NODE_MODULE_VERSION to 115 (Michaël Zasso) #47251
* [3803b02] - (SEMVER-MAJOR) src: share common code paths for SEA and embedder script (Anna Henningsen) #46825
* [e8bddac] - (SEMVER-MAJOR) src: apply ABI-breaking API simplifications (Anna Henningsen) #46705
* [f84de0a] - (SEMVER-MAJOR) src: use uint32_t for process initialization flags enum (Anna Henningsen) #46427
* [a624277] - (SEMVER-MAJOR) src: fix ArrayBuffer::Detach deprecation (Michaël Zasso) #45579
* [dd5c39a] - (SEMVER-MAJOR) src: update NODE_MODULE_VERSION to 112 (Yagiz Nizipli) #45579
* [63eca7f] - (SEMVER-MAJOR) stream: validate readable defaultEncoding (Marco Ippolito) #46430
* [9e7093f] - (SEMVER-MAJOR) stream: validate writable defaultEncoding (Marco Ippolito) #46322
* [fb91ee4] - (SEMVER-MAJOR) test: make trace-gc-flag tests less strict (Yagiz Nizipli) #45579
* [eca6180] - (SEMVER-MAJOR) test: adapt test-v8-stats for V8 update (Michaël Zasso) #45579
* [c03354d] - (SEMVER-MAJOR) test: test case for multiple res.writeHead and res.getHeader (Marco Ippolito) #45508
* [c733cc0] - (SEMVER-MAJOR) test_runner: mark module as stable (Colin Ihrig) #46983
* [7ce2232] - (SEMVER-MAJOR) tools: update V8 gypfiles for 11.1 (Michaël Zasso) #47251
* [ca4bd30] - (SEMVER-MAJOR) tools: update V8 gypfiles for 11.0 (Michaël Zasso) #47251
* [58b06a2] - (SEMVER-MAJOR) tools: update V8 gypfiles (Michaël Zasso) #45579
* [027841c] - (SEMVER-MAJOR) url: use private properties for brand check (Yagiz Nizipli) #46904
* [3bed5f1] - (SEMVER-MAJOR) url: runtime-deprecate url.parse() with invalid ports (Rich Trott) #45526
* [7c76fdd] - (SEMVER-MAJOR) util,doc: mark parseArgs() as stable (Colin Ihrig) #46718
* [4b52727] - (SEMVER-MAJOR) wasi: make version non-optional (Michael Dawson) #47391

Signed-off-by: RafaelGSS <[email protected]>

PR-URL: #47441
Signed-off-by: RafaelGSS <[email protected]>
RafaelGSS added a commit that referenced this pull request Apr 17, 2023
Notable Changes:

crypto:
  * (SEMVER-MAJOR) use WebIDL converters in WebCryptoAPI (Filip Skokan) #46067
deps:
  * update ada to 2.0.0 (Node.js GitHub Bot) #47339
esm:
  * move hook execution to separate thread (Jacob Smith) #44710
sea:
  * use JSON configuration and blob content for SEA (Joyee Cheung) #47125
src,process:
  * (SEMVER-MINOR) add permission model (Rafael Gonzaga) #44004
url:
  * drop ICU requirement for parsing hostnames (Yagiz Nizipli) #47339
  * use ada::url_aggregator for parsing urls (Yagiz Nizipli) #47339
  * (SEMVER-MAJOR) runtime-deprecate url.parse() with invalid ports (Rich Trott) #45526

Semver-Major Commits:

* [9fafb0a] - (SEMVER-MAJOR) async_hooks: deprecate the AsyncResource.bind asyncResource property (James M Snell) #46432
* [1948d37] - (SEMVER-MAJOR) buffer: check INSPECT_MAX_BYTES with validateNumber (Umuoy) #46599
* [7bc0e6a] - (SEMVER-MAJOR) buffer: graduate File from experimental and expose as global (Khafra) #47153
* [671ffd7] - (SEMVER-MAJOR) buffer: use min/max of `validateNumber` (Deokjin Kim) #45796
* [ab1614d] - (SEMVER-MAJOR) build: reset embedder string to "-node.0" (Michaël Zasso) #47251
* [c1bcdbc] - (SEMVER-MAJOR) build: warn for gcc versions earlier than 10.1 (Richard Lau) #46806
* [649f68f] - (SEMVER-MAJOR) build: reset embedder string to "-node.0" (Yagiz Nizipli) #45579
* [9374700] - (SEMVER-MAJOR) crypto: remove DEFAULT_ENCODING (Tobias Nießen) #47182
* [1640aeb] - (SEMVER-MAJOR) crypto: remove obsolete SSL_OP_* constants (Tobias Nießen) #47073
* [c2e4b1f] - (SEMVER-MAJOR) crypto: remove ALPN_ENABLED (Tobias Nießen) #47028
* [3ef38c4] - (SEMVER-MAJOR) crypto: use WebIDL converters in WebCryptoAPI (Filip Skokan) #46067
* [08af023] - (SEMVER-MAJOR) crypto: runtime deprecate replaced rsa-pss keygen parameters (Filip Skokan) #45653
* [7eb0ac3] - (SEMVER-MAJOR) deps: patch V8 to support compilation on win-arm64 (Michaël Zasso) #47251
* [a7c129f] - (SEMVER-MAJOR) deps: silence irrelevant V8 warning (Michaël Zasso) #47251
* [6f5655a] - (SEMVER-MAJOR) deps: always define V8_EXPORT_PRIVATE as no-op (Michaël Zasso) #47251
* [f226350] - (SEMVER-MAJOR) deps: update V8 to 11.3.244.4 (Michaël Zasso) #47251
* [d6dae74] - (SEMVER-MAJOR) deps: V8: cherry-pick f1c888e7093e (Michaël Zasso) #45579
* [56c4365] - (SEMVER-MAJOR) deps: fix V8 build on Windows with MSVC (Michaël Zasso) #45579
* [51ab98c] - (SEMVER-MAJOR) deps: silence irrelevant V8 warning (Michaël Zasso) #45579
* [9f84d3e] - (SEMVER-MAJOR) deps: V8: fix v8-cppgc.h for MSVC (Jiawen Geng) #45579
* [f2318cd] - (SEMVER-MAJOR) deps: fix V8 build issue with inline methods (Jiawen Geng) #45579
* [16e03e7] - (SEMVER-MAJOR) deps: update V8 to 10.9.194.4 (Yagiz Nizipli) #45579
* [6473f5e] - (SEMVER-MAJOR) doc: update toolchains used for Node.js 20 releases (Richard Lau) #47352
* [cc18fd9] - (SEMVER-MAJOR) events: refactor to use `validateNumber` (Deokjin Kim) #45770
* [ff92b40] - (SEMVER-MAJOR) http: close the connection after sending a body without declared length (Tim Perry) #46333
* [2a29df6] - (SEMVER-MAJOR) http: keep HTTP/1.1 conns alive even if the Connection header is removed (Tim Perry) #46331
* [391dc74] - (SEMVER-MAJOR) http: throw error if options of http.Server is array (Deokjin Kim) #46283
* [ed3604c] - (SEMVER-MAJOR) http: server check Host header, to meet RFC 7230 5.4 requirement (wwwzbwcom) #45597
* [88d71dc] - (SEMVER-MAJOR) lib: refactor to use min/max of `validateNumber` (Deokjin Kim) #45772
* [e4d641f] - (SEMVER-MAJOR) lib: refactor to use validators in http2 (Debadree Chatterjee) #46174
* [0f3e531] - (SEMVER-MAJOR) lib: performance improvement on readline async iterator (Thiago Oliveira Santos) #41276
* [5b5898a] - (SEMVER-MAJOR) lib,src: update exit codes as per todos (Debadree Chatterjee) #45841
* [55321ba] - (SEMVER-MAJOR) net: enable autoSelectFamily by default (Paolo Insogna) #46790
* [2d0d997] - (SEMVER-MAJOR) process: remove `process.exit()`, `process.exitCode` coercion to integer (Daeyeon Jeong) #43716
* [dc06df3] - (SEMVER-MAJOR) readline: refactor to use `validateNumber` (Deokjin Kim) #45801
* [295b2f3] - (SEMVER-MAJOR) src: update NODE_MODULE_VERSION to 115 (Michaël Zasso) #47251
* [3803b02] - (SEMVER-MAJOR) src: share common code paths for SEA and embedder script (Anna Henningsen) #46825
* [e8bddac] - (SEMVER-MAJOR) src: apply ABI-breaking API simplifications (Anna Henningsen) #46705
* [f84de0a] - (SEMVER-MAJOR) src: use uint32_t for process initialization flags enum (Anna Henningsen) #46427
* [a624277] - (SEMVER-MAJOR) src: fix ArrayBuffer::Detach deprecation (Michaël Zasso) #45579
* [dd5c39a] - (SEMVER-MAJOR) src: update NODE_MODULE_VERSION to 112 (Yagiz Nizipli) #45579
* [63eca7f] - (SEMVER-MAJOR) stream: validate readable defaultEncoding (Marco Ippolito) #46430
* [9e7093f] - (SEMVER-MAJOR) stream: validate writable defaultEncoding (Marco Ippolito) #46322
* [fb91ee4] - (SEMVER-MAJOR) test: make trace-gc-flag tests less strict (Yagiz Nizipli) #45579
* [eca6180] - (SEMVER-MAJOR) test: adapt test-v8-stats for V8 update (Michaël Zasso) #45579
* [c03354d] - (SEMVER-MAJOR) test: test case for multiple res.writeHead and res.getHeader (Marco Ippolito) #45508
* [c733cc0] - (SEMVER-MAJOR) test_runner: mark module as stable (Colin Ihrig) #46983
* [7ce2232] - (SEMVER-MAJOR) tools: update V8 gypfiles for 11.1 (Michaël Zasso) #47251
* [ca4bd30] - (SEMVER-MAJOR) tools: update V8 gypfiles for 11.0 (Michaël Zasso) #47251
* [58b06a2] - (SEMVER-MAJOR) tools: update V8 gypfiles (Michaël Zasso) #45579
* [027841c] - (SEMVER-MAJOR) url: use private properties for brand check (Yagiz Nizipli) #46904
* [3bed5f1] - (SEMVER-MAJOR) url: runtime-deprecate url.parse() with invalid ports (Rich Trott) #45526
* [7c76fdd] - (SEMVER-MAJOR) util,doc: mark parseArgs() as stable (Colin Ihrig) #46718
* [4b52727] - (SEMVER-MAJOR) wasi: make version non-optional (Michael Dawson) #47391

Signed-off-by: RafaelGSS <[email protected]>

PR-URL: #47441
Signed-off-by: RafaelGSS <[email protected]>
RafaelGSS added a commit that referenced this pull request Apr 18, 2023
Notable Changes:

crypto:
  * (SEMVER-MAJOR) use WebIDL converters in WebCryptoAPI (Filip Skokan) #46067
deps:
  * update ada to 2.0.0 (Node.js GitHub Bot) #47339
esm:
  * move hook execution to separate thread (Jacob Smith) #44710
sea:
  * use JSON configuration and blob content for SEA (Joyee Cheung) #47125
src,process:
  * (SEMVER-MINOR) add permission model (Rafael Gonzaga) #44004
url:
  * drop ICU requirement for parsing hostnames (Yagiz Nizipli) #47339
  * use ada::url_aggregator for parsing urls (Yagiz Nizipli) #47339
  * (SEMVER-MAJOR) runtime-deprecate url.parse() with invalid ports (Rich Trott) #45526

Semver-Major Commits:

* [9fafb0a] - (SEMVER-MAJOR) async_hooks: deprecate the AsyncResource.bind asyncResource property (James M Snell) #46432
* [1948d37] - (SEMVER-MAJOR) buffer: check INSPECT_MAX_BYTES with validateNumber (Umuoy) #46599
* [7bc0e6a] - (SEMVER-MAJOR) buffer: graduate File from experimental and expose as global (Khafra) #47153
* [671ffd7] - (SEMVER-MAJOR) buffer: use min/max of `validateNumber` (Deokjin Kim) #45796
* [ab1614d] - (SEMVER-MAJOR) build: reset embedder string to "-node.0" (Michaël Zasso) #47251
* [c1bcdbc] - (SEMVER-MAJOR) build: warn for gcc versions earlier than 10.1 (Richard Lau) #46806
* [649f68f] - (SEMVER-MAJOR) build: reset embedder string to "-node.0" (Yagiz Nizipli) #45579
* [9374700] - (SEMVER-MAJOR) crypto: remove DEFAULT_ENCODING (Tobias Nießen) #47182
* [1640aeb] - (SEMVER-MAJOR) crypto: remove obsolete SSL_OP_* constants (Tobias Nießen) #47073
* [c2e4b1f] - (SEMVER-MAJOR) crypto: remove ALPN_ENABLED (Tobias Nießen) #47028
* [3ef38c4] - (SEMVER-MAJOR) crypto: use WebIDL converters in WebCryptoAPI (Filip Skokan) #46067
* [08af023] - (SEMVER-MAJOR) crypto: runtime deprecate replaced rsa-pss keygen parameters (Filip Skokan) #45653
* [7eb0ac3] - (SEMVER-MAJOR) deps: patch V8 to support compilation on win-arm64 (Michaël Zasso) #47251
* [a7c129f] - (SEMVER-MAJOR) deps: silence irrelevant V8 warning (Michaël Zasso) #47251
* [6f5655a] - (SEMVER-MAJOR) deps: always define V8_EXPORT_PRIVATE as no-op (Michaël Zasso) #47251
* [f226350] - (SEMVER-MAJOR) deps: update V8 to 11.3.244.4 (Michaël Zasso) #47251
* [d6dae74] - (SEMVER-MAJOR) deps: V8: cherry-pick f1c888e7093e (Michaël Zasso) #45579
* [56c4365] - (SEMVER-MAJOR) deps: fix V8 build on Windows with MSVC (Michaël Zasso) #45579
* [51ab98c] - (SEMVER-MAJOR) deps: silence irrelevant V8 warning (Michaël Zasso) #45579
* [9f84d3e] - (SEMVER-MAJOR) deps: V8: fix v8-cppgc.h for MSVC (Jiawen Geng) #45579
* [f2318cd] - (SEMVER-MAJOR) deps: fix V8 build issue with inline methods (Jiawen Geng) #45579
* [16e03e7] - (SEMVER-MAJOR) deps: update V8 to 10.9.194.4 (Yagiz Nizipli) #45579
* [6473f5e] - (SEMVER-MAJOR) doc: update toolchains used for Node.js 20 releases (Richard Lau) #47352
* [cc18fd9] - (SEMVER-MAJOR) events: refactor to use `validateNumber` (Deokjin Kim) #45770
* [ff92b40] - (SEMVER-MAJOR) http: close the connection after sending a body without declared length (Tim Perry) #46333
* [2a29df6] - (SEMVER-MAJOR) http: keep HTTP/1.1 conns alive even if the Connection header is removed (Tim Perry) #46331
* [391dc74] - (SEMVER-MAJOR) http: throw error if options of http.Server is array (Deokjin Kim) #46283
* [ed3604c] - (SEMVER-MAJOR) http: server check Host header, to meet RFC 7230 5.4 requirement (wwwzbwcom) #45597
* [88d71dc] - (SEMVER-MAJOR) lib: refactor to use min/max of `validateNumber` (Deokjin Kim) #45772
* [e4d641f] - (SEMVER-MAJOR) lib: refactor to use validators in http2 (Debadree Chatterjee) #46174
* [0f3e531] - (SEMVER-MAJOR) lib: performance improvement on readline async iterator (Thiago Oliveira Santos) #41276
* [5b5898a] - (SEMVER-MAJOR) lib,src: update exit codes as per todos (Debadree Chatterjee) #45841
* [55321ba] - (SEMVER-MAJOR) net: enable autoSelectFamily by default (Paolo Insogna) #46790
* [2d0d997] - (SEMVER-MAJOR) process: remove `process.exit()`, `process.exitCode` coercion to integer (Daeyeon Jeong) #43716
* [dc06df3] - (SEMVER-MAJOR) readline: refactor to use `validateNumber` (Deokjin Kim) #45801
* [295b2f3] - (SEMVER-MAJOR) src: update NODE_MODULE_VERSION to 115 (Michaël Zasso) #47251
* [3803b02] - (SEMVER-MAJOR) src: share common code paths for SEA and embedder script (Anna Henningsen) #46825
* [e8bddac] - (SEMVER-MAJOR) src: apply ABI-breaking API simplifications (Anna Henningsen) #46705
* [f84de0a] - (SEMVER-MAJOR) src: use uint32_t for process initialization flags enum (Anna Henningsen) #46427
* [a624277] - (SEMVER-MAJOR) src: fix ArrayBuffer::Detach deprecation (Michaël Zasso) #45579
* [dd5c39a] - (SEMVER-MAJOR) src: update NODE_MODULE_VERSION to 112 (Yagiz Nizipli) #45579
* [63eca7f] - (SEMVER-MAJOR) stream: validate readable defaultEncoding (Marco Ippolito) #46430
* [9e7093f] - (SEMVER-MAJOR) stream: validate writable defaultEncoding (Marco Ippolito) #46322
* [fb91ee4] - (SEMVER-MAJOR) test: make trace-gc-flag tests less strict (Yagiz Nizipli) #45579
* [eca6180] - (SEMVER-MAJOR) test: adapt test-v8-stats for V8 update (Michaël Zasso) #45579
* [c03354d] - (SEMVER-MAJOR) test: test case for multiple res.writeHead and res.getHeader (Marco Ippolito) #45508
* [c733cc0] - (SEMVER-MAJOR) test_runner: mark module as stable (Colin Ihrig) #46983
* [7ce2232] - (SEMVER-MAJOR) tools: update V8 gypfiles for 11.1 (Michaël Zasso) #47251
* [ca4bd30] - (SEMVER-MAJOR) tools: update V8 gypfiles for 11.0 (Michaël Zasso) #47251
* [58b06a2] - (SEMVER-MAJOR) tools: update V8 gypfiles (Michaël Zasso) #45579
* [027841c] - (SEMVER-MAJOR) url: use private properties for brand check (Yagiz Nizipli) #46904
* [3bed5f1] - (SEMVER-MAJOR) url: runtime-deprecate url.parse() with invalid ports (Rich Trott) #45526
* [7c76fdd] - (SEMVER-MAJOR) util,doc: mark parseArgs() as stable (Colin Ihrig) #46718
* [4b52727] - (SEMVER-MAJOR) wasi: make version non-optional (Michael Dawson) #47391

Signed-off-by: RafaelGSS <[email protected]>

PR-URL: #47441
Signed-off-by: RafaelGSS <[email protected]>
@iambumblehead
Copy link

What is the recommended way to pass data from the main thread to a loader? Thanks in advance for any reply

@iambumblehead
Copy link

I see it is documented here (sorry for bothering) https://nodejs.org/api/esm.html#globalpreload I'll play around with this

@JakobJingleheimer JakobJingleheimer deleted the feat/esm_off-thread-loaders branch June 1, 2023 17:05
@danielleadams danielleadams added the backport-requested-v18.x PRs awaiting manual backport to the v18.x-staging branch. label Jun 12, 2023
@kirrg001
Copy link

We are unable to access the app path with ESM loaders being off threaded in v20 easily. See nodejs/help#4190
Wondering if you are aware of a better solution than the one I've shared in the help issue. Thanks

@lukeed
Copy link

lukeed commented Jun 27, 2023

Looks like loaders no longer have access to process.argv

@JakobJingleheimer
Copy link
Contributor Author

JakobJingleheimer commented Jun 27, 2023

Looks like loaders no longer have access to process.argv

Correct; that is how worker threads work. There is a dedicated issue for this as well as a proposal to address (which is already linked).

I'm locking this as most of the recent comments are telling us the sky is blue.

@nodejs nodejs locked and limited conversation to collaborators Jun 27, 2023
@ruyadorno
Copy link
Member

It looks like this should be marked as a semver-major and we should avoid backporting it to v18.x, @nodejs/loaders thoughts?

@aduh95
Copy link
Contributor

aduh95 commented Jun 29, 2023

Marking it as semver-major would be wrong I think, because it's an experimental API, but it could be labelled as dont-land-on-v18.x though.
That being said, I think we do want to backport it to v18.x, but that cannot happen until the ecosystem is ready for it, so backport-requested is actually the correct place for this PR to be atm if we follow that plan.

@targos targos added backported-to-v18.x PRs backported to the v18.x-staging branch. and removed backport-requested-v18.x PRs awaiting manual backport to the v18.x-staging branch. labels Nov 23, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
author ready PRs that have at least one approval, no pending requests for changes, and a CI started. backported-to-v18.x PRs backported to the v18.x-staging branch. esm Issues and PRs related to the ECMAScript Modules implementation. lib / src Issues and PRs related to general changes in the lib or src directory. loaders Issues and PRs related to ES module loaders needs-ci PRs that need a full CI run. notable-change PRs with changes that should be highlighted in changelogs.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

esm, loader: move to own thread