-
-
Notifications
You must be signed in to change notification settings - Fork 34
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
feat: support Bun #70
Conversation
@@ -38,6 +38,12 @@ parentPort!.on('message', (message: StartupMessage) => { | |||
useAtomics = | |||
process.env.PISCINA_DISABLE_ATOMICS === '1' ? false : message.useAtomics | |||
|
|||
if (useAtomics && process.versions.bun) { | |||
const error = 'useAtomics cannot be used with Bun at the moment.' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Workers are unable to terminate when using bun. I think the while loops below are causing it. oven-sh/bun#4134
import { isMainThread, Worker } from "node:worker_threads";
import { fileURLToPath } from "node:url";
if (isMainThread) {
console.log("[main] running");
const worker = new Worker(fileURLToPath(import.meta.url));
await new Promise((r) => setTimeout(r, 1_000));
const timeout = setTimeout(() => console.error("Timeout"), 2_000);
console.log("[main] terminating");
await worker.terminate();
clearTimeout(timeout);
console.log("[main] terminated");
} else {
console.log("[worker] running");
while (true) {}
}
ari ~/repro $ node worker-threads.mjs
[main] running
[worker] running
[main] terminating
[main] terminated
ari ~/repro $ bun worker-threads.mjs
[main] running
[worker] running
[main] terminating
Timeout
<stuck here>
529b5ff
to
69d2828
Compare
69d2828
to
6f72bda
Compare
Let's wait for fixes from Bun before moving on. Adding work-arounds just for Bun doesn't feel right. |
- Instead of using Node APIs like in tinylibs#70, use Bun's native Workers API
- Instead of using Node APIs like in tinylibs#70, use Bun's native Workers API
- Instead of using Node APIs like in tinylibs#70, use Bun's native Workers API
Adding Bun support for Node APIs like Let's instead add support for Bun's native |
- Instead of using Node APIs like in tinylibs#70, use Bun's native Workers API
- Instead of using Node APIs like in tinylibs#70, use Bun's native Workers API
- Instead of using Node APIs like in tinylibs#70, use Bun's native Workers API
Related to vitest-dev/vitest#4111
node:worker_threads
are unstable on Bun and crash under heavy loadnode:worker_threads
get stuck on Bun if there arewhile(true) {}
loops inside the workerWorker
s are unstable, leak memory and crash under heavy loadMessagePort
s automatically,port.start()
must be called manuallynode:child_process
immediately like NodeJS does. It also does not emitspawn
event. Manual work-arounds are required.Sometimes Bun crashes with
libc++abi: Pure virtual function called! Abort trap: 6
error.