LearnNewsExamplesServices
Frontmatter
id8818
titleImplement Node.js Unhandled Rejection Handler for Neo.isDestroyed
stateClosed
labels
bugtestingcore
assigneestobiu
createdAtJan 19, 2026, 7:20 PM
updatedAtJan 19, 2026, 7:22 PM
githubUrlhttps://github.com/neomjs/neo/issues/8818
authortobiu
commentsCount1
parentIssuenull
subIssues[]
subIssuesCompleted0
subIssuesTotal0
blockedBy[]
blocking[]
closedAtJan 19, 2026, 7:22 PM

Implement Node.js Unhandled Rejection Handler for Neo.isDestroyed

Closed v11.23.0 bugtestingcore
tobiu
tobiu commented on Jan 19, 2026, 7:20 PM

Neo.mjs has a global unhandledrejection handler that intercepts and suppresses Neo.isDestroyed errors, preventing crashes when asynchronous operations complete after component destruction. However, this handler relied on globalThis.addEventListener, which is not available in Node.js environments (used for Middleware and Unit Tests).

This caused Node.js processes to crash or warn on Neo.isDestroyed rejections, complicating testing and potentially destabilizing server-side rendering.

Fix: Added a Node.js-specific handler using process.on('unhandledRejection') to src/Neo.mjs. This handler mirrors the browser behavior: it suppresses Neo.isDestroyed and re-throws all other errors. Added documentation to clarify the environment-specific handling (Browser/Worker vs Node.js).

tobiu added the bug label on Jan 19, 2026, 7:20 PM
tobiu added the testing label on Jan 19, 2026, 7:20 PM
tobiu added the core label on Jan 19, 2026, 7:20 PM
tobiu referenced in commit bf109a5 - "feat: Implement Node.js unhandledRejection handler for Neo.isDestroyed (#8818)" on Jan 19, 2026, 7:20 PM
tobiu assigned to @tobiu on Jan 19, 2026, 7:20 PM
tobiu
tobiu Jan 19, 2026, 7:21 PM

Input from Gemini 3 Pro:

✦ I have implemented the Node.js unhandledRejection handler in src/Neo.mjs to mirror the browser's behavior for Neo.isDestroyed errors. This ensures that the trap() pattern works correctly in Middleware and Unit Testing environments without crashing the process, while still allowing other unhandled rejections to fail/crash as expected. I also added comments to clearly distinguish the Browser/Worker path from the Node.js path.

tobiu closed this issue on Jan 19, 2026, 7:22 PM