Version
v24.x main
Proposed change
A worker that inherits parent execArgv should apply an inherited --vfs-load mount before resolving its entry file, including when the parent also uses --import.
Current behavior
lib/internal/main/worker_thread.js only calls finishVfsMounts() before loading the worker when there are no imports:
if (imports.length === 0) {
finishVfsMounts()
}
The file-worker path reaches Module.runMain(filename), which calls resolveMainPath() before runEntryPointWithESMLoader() installs the inherited VFS mount. A worker entry inside the inherited VFS therefore fails to resolve when the parent command also contains --import.
Steps to reproduce
Create noop.mjs, then:
// app/index.js
const path = require('node:path')
const {Worker} = require('node:worker_threads')
new Worker(path.join(__dirname, 'worker.js'))
.on('message', console.log)
.on('error', console.error)
// app/worker.js
require('node:worker_threads').parentPort.postMessage('ok')
Run:
node --experimental-vfs --import ./noop.mjs --vfs-load ./app
Expected: the worker loads app/worker.js from the inherited VFS and prints ok.
Actual: worker entry resolution happens before the inherited mount is installed, so loading fails.
Regression test
Extend test/parallel/test-vfs-load.js with the existing inherited-worker scenario and an otherwise empty --import preload.
I found no existing issue or PR covering --vfs-load together with --import for inherited workers.
Version
v24.x main
Proposed change
A worker that inherits parent
execArgvshould apply an inherited--vfs-loadmount before resolving its entry file, including when the parent also uses--import.Current behavior
lib/internal/main/worker_thread.jsonly callsfinishVfsMounts()before loading the worker when there are no imports:The file-worker path reaches
Module.runMain(filename), which callsresolveMainPath()beforerunEntryPointWithESMLoader()installs the inherited VFS mount. A worker entry inside the inherited VFS therefore fails to resolve when the parent command also contains--import.Steps to reproduce
Create
noop.mjs, then:Run:
node --experimental-vfs --import ./noop.mjs --vfs-load ./appExpected: the worker loads
app/worker.jsfrom the inherited VFS and printsok.Actual: worker entry resolution happens before the inherited mount is installed, so loading fails.
Regression test
Extend
test/parallel/test-vfs-load.jswith the existing inherited-worker scenario and an otherwise empty--importpreload.I found no existing issue or PR covering
--vfs-loadtogether with--importfor inherited workers.