bun icon indicating copy to clipboard operation
bun copied to clipboard

Worker not handling message events when the thread is blocked

Open Exitium-DEV opened this issue 5 months ago • 1 comments

What version of Bun is running?

1.1.20

What platform is your computer?

Microsoft Windows NT 10.0.22621.0 x64

What steps can reproduce the bug?

Create a file (worker.ts) with the following code

self.onmessage = async (event: MessageEvent) => {
    console.log(event.data);
}

while (true) {
    console.log(new Date().toLocaleTimeString());
    await new Promise((resolve) => setTimeout(resolve, 1000));
};

export {};

then call the worker from the main thread (in another file), and send any message, the worker will not respond as the while (true) loop is active, despite the message handler being asynchronous

What is the expected behavior?

the while loop to remain active the worker to print the message sent to it in the stdout

What do you see instead?

just the time (from the while loop)

Additional information

No response

Exitium-DEV avatar Aug 27 '24 13:08 Exitium-DEV