-
-
Notifications
You must be signed in to change notification settings - Fork 1.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
[Bug] pnpapi.setup()
in main thread not affecting worker threads
#2476
Comments
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Hmm.. that wasn't the error I was expecting. Looks like some how the sherlock environment cannot directly |
This comment has been minimized.
This comment has been minimized.
This issue reproduces on master:
|
More investigation: The core of the issue is how (the various ways of setting) the cosnt tests = [
/* 1 */ () => {
const worker = new Worker(__filename)
},
/* 2 */ () => {
const orig = process.execArgv
process.execArgv = ['--require', './preload.js', ...process.execArgv]
const worker = new Worker(__filename)
process.execArgv = orig
},
/* 3 */ () => {
const worker = new Worker(__filename, { execArgv: ['--require', './preload.js', ...process.execArgv] })
},
/* 4 */ () => {
const orig = process.env.NODE_OPTIONS
process.env.NODE_OPTIONS = `--require ./preload.js ${process.env.NODE_OPTIONS}`
const worker = new Worker(__filename)
process.env.NODE_OPTIONS = orig
},
/* 5 */ () => {
const orig = process.env.NODE_OPTIONS
process.env.NODE_OPTIONS = `--require ./preload.js ${process.env.NODE_OPTIONS}`
const worker = new Worker(__filename, { env: SHARE_ENV })
process.env.NODE_OPTIONS = orig
},
/* 6 */ () => {
const worker = new Worker(__filename, { env: { NODE_OPTIONS: `--require ./preload.js ${process.env.NODE_OPTIONS}` } })
},
] where console.log('preload', process.pid, require('worker_threads').threadId) Out of these, only 3 and 6 (explicitly passing I also tested the equivalent invocations of cosnt tests = [
/* 1 */ () => {
const cp = fork('./foo.js')
},
/* 2 */ () => {
const orig = process.execArgv
process.execArgv = ['--require', './preload.js', ...process.execArgv]
const cp = fork('./foo.js')
process.execArgv = orig
},
/* 3 */ () => {
const cp = fork('./foo.js', { execArgv: ['--require', './preload.js', ...process.execArgv] })
},
/* 4 */ () => {
const orig = process.env.NODE_OPTIONS
process.env.NODE_OPTIONS = `--require ./preload.js ${process.env.NODE_OPTIONS}`
const cp = fork('./foo.js')
process.env.NODE_OPTIONS = orig
},
/* 6 */ () => {
const cp = fork('./foo.js', { env: { NODE_OPTIONS: `--require ./preload.js ${process.env.NODE_OPTIONS}` } })
},
] Out of these, all but 1 works. This show there is a discrepancy between how Question: Should we just handle it in Yarn (e.g. monkey-patch |
Describe the bug
Calling
pnpapi.setup()
in the main thread does not set up PnP insider worker threads, causing worker threads to fail whenrequire
-ing dependencies.This affects stuff like the eslint pnpify sdk, since that just calls
pnpapi.setup()
and eslint plugins may spawn worker threads.To Reproduce
Reproduction
Environment if relevant (please complete the following information):
The text was updated successfully, but these errors were encountered: