node icon indicating copy to clipboard operation
node copied to clipboard

worker: allow copied NODE_OPTIONS in the env setting

Open joyeecheung opened this issue 1 year ago • 2 comments

When the worker spawning code copies NODE_OPTIONS from process.env, previously we do a check again on the copied NODE_OPTIONS and throw if it contains per-process settings. This can be problematic if the end user starts the process with a NODE_OPTIONS and the worker is spawned by a third-party that tries to extend process.env with some overrides before passing them into the worker. This patch adds another exception that skips the validation if the NODE_OPTIONS in the env setting is character-by-character equal to the parent NODE_OPTIONS. While some more intelligent filter can be useful too, this works good enough for the inheritance case, when the worker spawning code does not intend to modify NODE_OPTIONS.

Refs: https://github.com/nodejs/node/issues/41103

joyeecheung avatar Jun 26 '24 17:06 joyeecheung

CI: https://ci.nodejs.org/job/node-test-pull-request/59982/

nodejs-github-bot avatar Jun 26 '24 18:06 nodejs-github-bot

CI: https://ci.nodejs.org/job/node-test-pull-request/59997/

nodejs-github-bot avatar Jun 27 '24 21:06 nodejs-github-bot

Fixed the linter error and skipped the main thread process.title assertion on SmartOS because the option itself isn't supported there. The assertion is only there in case someone runs the test locally without --title and isn't essential to what this tries to implement here (that the worker can inherit the option as-is without erroring). --title is picked because it's the most straightforward to test among all the per-process options.

joyeecheung avatar Jul 04 '24 17:07 joyeecheung

CI: https://ci.nodejs.org/job/node-test-pull-request/60089/

nodejs-github-bot avatar Jul 05 '24 00:07 nodejs-github-bot

@legendecas @jasnell @meixg can you take a look again? Thanks!

joyeecheung avatar Jul 05 '24 16:07 joyeecheung

Landed in b32c7229d536cd0dfb967f297759991849481755

nodejs-github-bot avatar Jul 05 '24 18:07 nodejs-github-bot