You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
import{parentPort}from"node:worker_threads";parentPort.on("message",()=>{console.log("received message");});while(true){// some sync code...awaitnewPromise((r)=>setImmediate(r));}
Run:
bun a.js
What is the expected behavior?
I expect to see the line in the callback being printed. Here's what happens when running this program through Node:
$ node src/a.js
received message
What do you see instead?
The program never prints anything, supposedly because the callback is never called in the first place.
Additional information
If you move the hot loop inside a function, and call it without awaiting it on the top-level code, it seems like the issue 'gets fixed', which leads me to believe Bun is probably treating top-level async/await differently.
As in:
asyncfunctiona(){while(true){// some sync code...awaitnewPromise((r)=>setImmediate(r));}}a();
The text was updated successfully, but these errors were encountered:
What version of Bun is running?
1.1.36
What platform is your computer?
Darwin 22.4.0 arm64 arm
What steps can reproduce the bug?
Create 2 files in the same folder:
a.js
b.js
Run:
What is the expected behavior?
I expect to see the line in the callback being printed. Here's what happens when running this program through Node:
What do you see instead?
The program never prints anything, supposedly because the callback is never called in the first place.
Additional information
If you move the hot loop inside a function, and call it without
await
ing it on the top-level code, it seems like the issue 'gets fixed', which leads me to believe Bun is probably treating top-levelasync/await
differently.As in:
The text was updated successfully, but these errors were encountered: