What version of Bun is running?
1.3.11-canary.1+9e93bfa1b
What platform is your computer?
Linux 5.10.0-12-amd64 x86_64 x86_64
What steps can reproduce the bug?
Hi,
I would like to report a behavior in Bun that can be reproduced using the below PoC:
- main.mjs
const worker = new Worker(new URL('./worker.mjs', import.meta.url).href, { type: 'module' });
worker.onmessage = ({ data }) => {
console.log('main got:', data);
};
worker.onerror = (e) => {
console.error('worker error:', e.message || e);
};
setTimeout(() => {
console.log('main done');
}, 1000);
- worker.mjs
self.postMessage('message');
// Closing immediately after postMessage should just terminate the worker
self.close();
What is the expected behavior?
Bun workers are missing self.close() (standard API), causing runtime errors.
self.close() should be available in the worker global scope
root@KContainer:~/5334# deno run -A main.mjs
main got: message
main done
What do you see instead?
root@KContainer:~/5334# bun run main.mjs
main got: message
worker error: 1 | self.postMessage('message');
2 | // Closing immediately after postMessage should just terminate the worker
3 | self.close();
^
TypeError: self.close is not a function. (In 'self.close()', 'self.close' is undefined)
at /5334/worker.mjs:3:6
at loadAndEvaluateModule (2:1)
main done
Additional information
No response
What version of Bun is running?
1.3.11-canary.1+9e93bfa1b
What platform is your computer?
Linux 5.10.0-12-amd64 x86_64 x86_64
What steps can reproduce the bug?
Hi,
I would like to report a behavior in Bun that can be reproduced using the below PoC:
What is the expected behavior?
Bun workers are missing
self.close()(standard API), causing runtime errors.self.close()should be available in the worker global scopeWhat do you see instead?
Additional information
No response