Comments (7)
In all fairness, this seems like a breaking change, especially since this feature is in the Release Candidate stage. I wouldn't expect such a drastic change in behavior, particularly in a minor release.
For us, the Angular CLI, this is quite a breaking change because in some of our workers, we want different resolutions, which differs from the main thread and that of other workers.
We could surely do some workarounds, but it was very convenient that workers supported custom ESM hooks separate from the main thread.
If this is the intended and desired behavior, IMHO, it should be implemented in a major release to comply with semantic versioning.
from node.
#52706 fixed a longstanding bug: #50752. We knew that this fix might surprise or break people, which is why we were waiting to fix this before making the API stable (and we still haven’t, in case any further issues arise). This is the point of the Release Candidate stage: to identify and fix issues like this.
I’m sorry that this change has inconvenienced you, but this is why we have experimental features and why they need to be allowed to change. If we couldn’t fix this bug until October with Node 23, and then we couldn’t backport the fix to the LTS lines, it would be April 2025 before a stable hooks API would be available on an LTS line. Many users are eager for this API to become stable so that they can rely on it, and stretching it out over years inconveniences them for the dubious benefit of protecting early adopters who knew what they were getting into by relying on an experimental API. We prioritize the larger group of users seeking stability over the early adopters.
from node.
FYI there are discussions for reverting that change. The discussion about that can continue in the other issue, marking this one as duplciate.
Duplicate of #53182
from node.
Installing a game (KH3) via Heroic, got an error regarding Node.js. Should I be concerned, and what should I do? Thanks in advance for any help.
from node.
/cc @nodejs/loaders @dygabo
from node.
this behaviour changed indeed with #52706. Passing execArgv
to new Worker
is not supported. Please see this PR as a trial to document the behaviour.
Please add the customization hook to the main thread and this will affect all created workers as described here.
app.js
will become:
const { Worker, isMainThread } = require("node:worker_threads");
if (!isMainThread) {
import("./test.mjs").then(console.log).catch(console.error);
} else {
new Worker("./app.js");
}
hooks.mjs
will stay the same.
reg.mjs
will be:
import { register } from "node:module";
import { pathToFileURL } from "node:url";
register("./hooks.mjs", pathToFileURL("./"));
and the application start will be:
node --import=./reg.mjs app.js
the customization hooks chain will be as mentioned the same on all threads and the output will be something like:
init
resolve: file:///test-loader-esm/app.js
resolve: file:///test-loader-esm/app.js
resolve: ./test.mjs
Error [ERR_MODULE_NOT_FOUND]: Cannot find module '/test-loader-esm/test.mjs' imported from /test-loader-esm/app.js
at finalizeResolution (node:internal/modules/esm/resolve:260:11)
at moduleResolve (node:internal/modules/esm/resolve:920:10)
at defaultResolve (node:internal/modules/esm/resolve:1119:11)
at nextResolve (node:internal/modules/esm/hooks:791:28)
at resolve (file:///test-loader-esm/hooks.mjs:7:10)
at nextResolve (node:internal/modules/esm/hooks:791:28)
at Hooks.resolve (node:internal/modules/esm/hooks:238:30)
at MessagePort.handleMessage (node:internal/modules/esm/worker:255:24)
at [nodejs.internal.kHybridDispatch] (node:internal/event_target:816:20)
at MessagePort.<anonymous> (node:internal/per_context/messageport:23:28) {
code: 'ERR_MODULE_NOT_FOUND',
url: 'file:///test-loader-esm/test.mjs'
}
from node.
I assume this is caused by #52706.
There a bug was fixed that every worker created a fresh hooks thread instead of using that one created by the main thread.
As a result calling module.register()
in a worker has no effect.
#53006 will improve the docs regarding this.
So you should register your hooks once for all in main thread before starting the worker.
from node.
Related Issues (20)
- sccache does not seem to use cache from `main` branch HOT 1
- On Windows (arm64?) custom loader stops receiving specifiers after resolving imports in an entry file HOT 6
- idm
- Missing 'error' handlers on EventEmitters can be difficult to debug HOT 9
- AbortSignal.any does not work on all sequences HOT 1
- Mocha-like root hooks for test runner HOT 21
- Sharing AsyncLocalStorage instance with customization hook HOT 4
- OOM - Segmentation fault (not ulimit, not cgroups, not max-space, not exhausted RAM) HOT 6
- URL.canParse('https://*.example.com') incorrectly returns true HOT 5
- Inconsistent behavior with crypto.KeyObject.from() and key usage flags for RSA encryption/decryption HOT 1
- [Bug]: Vite Wallet does not run correctly after building it on Microsoft Windows. HOT 1
- Random wrong encoding of strings returned by .replace function HOT 1
- nodejs crashes at stream.c due to queue size assertion HOT 5
- Flaky text encoding regression in Node 22 HOT 1
- Reuse Blob Registry in Workers
- exec command 'playerctl status' does not work HOT 1
- test_runner: `latest.js` file is included by default HOT 1
- `cpSync` symlink handling regression HOT 3
- Node-API V8 Fast API HOT 2
- Nominating @abmusse to be a collaborator HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from node.