mirror of
https://github.com/oven-sh/bun
synced 2026-02-11 11:29:02 +00:00
Setting a global onmessage handler in the main thread (e.g., by the lzma package) was incorrectly keeping the event loop alive and preventing the process from exiting. The issue was in BunWorkerGlobalScope.cpp where adding a message event listener would always call refEventLoop(), even in the main thread. This was intended for worker threads where message listeners should keep the worker alive while waiting for messages from the parent. The fix adds a check to only ref/unref the event loop for message listeners when we're in a worker thread (not the main thread). Main thread message handlers are now correctly treated as passive listeners that don't prevent process exit. Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>