Skip to content

Commit 798d543

Browse files
committed
should work in workers
1 parent 658895f commit 798d543

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

lib/internal/main/worker_thread.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,10 +106,10 @@ port.on('message', (message) => {
106106
require('internal/process/policy').setup(manifestSrc, manifestURL);
107107
}
108108
initializeDeprecations();
109-
initializeFrozenIntrinsics();
110109
initializeCJSLoader();
111110
initializeESMLoader();
112111
loadPreloadModules();
112+
initializeFrozenIntrinsics();
113113
publicWorker.parentPort = publicPort;
114114
publicWorker.workerData = workerData;
115115

test/parallel/test-preload.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,14 @@ childProcess.exec(
7171
assert.strictEqual(stdout, 'hello\n');
7272
}
7373
);
74+
const workerSrc = `const {Worker} = require('worker_threads');new Worker(${JSON.stringify(fixtureA)});`;
75+
childProcess.exec(
76+
`"${nodeBinary}" --frozen-intrinsics ${preloadOption([fixtureE])}-e ${JSON.stringify(workerSrc)}`,
77+
function(err, stdout) {
78+
assert.ifError(err);
79+
assert.strictEqual(stdout, 'A\n');
80+
}
81+
);
7482

7583
// Test that preload can be used with stdin
7684
const stdinProc = childProcess.spawn(

0 commit comments

Comments
 (0)