-
Notifications
You must be signed in to change notification settings - Fork 30.1k
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
--conditions xxx
cannot pass into worker_thread
#50885
Comments
worker_thread
--conditions xxx
cannot pass into worker_thread
I think I can work on this one <3 Thanks for the report |
Appreciate it |
For whatever reason, Node.js is creating three workers, the first one is receiving and setting the context, as expected, but the next two are not, I'm still working on it |
Oh yes, the loader now lives on a worker thread; I'll see how I could send the |
When the `--conditions` is sent to a worker thread, it should affect the worker thread with the ESM loader on it. This patch sends the `execArgv` to the ESM worker. Signed-off-by: Juan José Arboleda <soyjuanarbol@gmail.com> Fixes: nodejs#50885
@nodejs/loaders |
I believe that the bug is more complex than I thought |
Please try this demo node ./main.js the output is this is pkg-a/react-server.cjs
this is pkg-b/index.cjs But I think it should be
|
This behavior is expected. You can pass |
@GeoffreyBooth |
This is weird thing. In this case, CJS module will have conditions but ESM module won't have |
I don't think the ESM worker needs more argv than |
So I think I misunderstood the original request. I guess the desire is that It so then I think finishing #50752 would resolve this, as |
I wonder if the bug here is actually just that If so, the fix might be as simple as including the That would fit my intuition, as the expectation is that |
No. The problem is that we are creating the ES worker w/out the parent's |
Ahh, ok so the loader is getting the top-level conditions, but not the explicit conditions passed to @GeoffreyBooth brings up a good point then as to whether the design we want here is one where all workers share the same global resolution context, or whether we want to enable This also extends to for example import maps support - would we expect the import map of the parent to be shared with the worker, or would we expect to be able to override that etc. These are important questions to get right. My personal preference would be to not treat worker spawning as a virtualization boundary, but to instead have transparent worker spawning in the same resolution context, while enabling virtualization through other virtualization-specific APIs that explicitly control the entire loader context. @GeoffreyBooth are these topics on the loaders agenda? I'd definitely be interested to join to discuss them further. |
They're not in the agenda but they could be if you want. The current behavior of a new hooks thread for each new application worker thread was accidental, and is considered a bug. I don't know if anyone is advocating for that behavior, and if not then I think we're already in alignment where we treat the hooks thread as derived from the initial environment/main thread like #50752 aims to achieve. |
When the `--conditions` is sent to a worker thread, it should affect the worker thread with the ESM loader on it. This patch sends the `execArgv` to the ESM worker. Signed-off-by: Juan José Arboleda <soyjuanarbol@gmail.com> Fixes: nodejs#50885
For what it is worth, I just ran into this issue while experimenting with React server components. |
Version
v20.10.0
Platform
Darwin Alexs-MacBook-Pro.local 23.1.0 Darwin Kernel Version 23.1.0: Mon Oct 9 21:28:45 PDT 2023; root:xnu-10002.41.9~6/RELEASE_ARM64_T6020 arm64
Subsystem
module
What steps will reproduce the bug?
How often does it reproduce? Is there a required condition?
No response
What is the expected behavior? Why is that the expected behavior?
What do you see instead?
Additional information
Might cause RSC bundle issue dai-shi/waku#178
The text was updated successfully, but these errors were encountered: