-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Open
Labels
Workeruses the web or node worker apiuses the web or node worker apibugSomething isn't workingSomething isn't working
Description
What version of Bun is running?
v1.2.16
What platform is your computer?
Windows
What steps can reproduce the bug?
const { Worker, SHARE_ENV } = require("worker_threads");
const worker = new Worker(variables.worker_path, {
env: SHARE_ENV,
});
What is the expected behavior?
It shouldn't throw an exception, the docs say it works and it previously didn't throw an exception.
What do you see instead?
After updating from v1.2.2 to v1.2.16, my worker thread throws the following exception:
====================
Exception[init]:
The "options.env" property must be of type object or one of undefined, null, or worker_threads.SHARE_ENV. Received type symbol (Symbol(nodejs.worker_threads.SHARE_ENV))
Stacktrace:
TypeError: The "options.env" property must be of type object or one of undefined, null, or worker_threads.SHARE_ENV. Received type symbol (Symbol(nodejs.worker_threads.SHARE_ENV))
at Worker (unknown)
at new Worker (node:worker_threads:152:35)
at new_worker (C:\Projects\node_game\src\worker.js:28:19)
at init_server (C:\Projects\node_game\src\utils\game-init-utils.js:317:2)
at <anonymous> (C:\Projects\node_game\src\server.js:658:5)
at <anonymous> (C:\Projects\node_game\src\utils\api-utils.js:119:19)
at <anonymous> (C:\Projects\node_game\node_modules\request\request.js:185:22)
at emit (node:events:338:22)
at <anonymous> (C:\Projects\node_game\node_modules\request\request.js:1154:10)
at emit (node:events:335:22)
at <anonymous> (C:\Projects\node_game\node_modules\request\request.js:1076:12)
at emit (node:events:332:22)
at endReadableNT (internal:streams/readable:359:50)
at processTicksAndRejections (native:7:39)
====================
Additional information
I think this was introduced in #18758.
Specifically, I noticed the following comment in the PR: https://github.com/oven-sh/bun/pull/18758/files#diff-31b0b04dff2468eb645784c28a3879f6fb5bfc056efec5144b0103ea9be56b35R228
// for now, we don't permit SHARE_ENV, because the behavior isn't implemented
So maybe it is a regression? Or maybe it never worked but was silently ignored.
EmNudge, JoshuaKGoldberg and sylvaindumont
Metadata
Metadata
Assignees
Labels
Workeruses the web or node worker apiuses the web or node worker apibugSomething isn't workingSomething isn't working