No unhandled promise rejections in production
Why it matters
Unhandled promise rejections crash Node.js server processes outright in newer runtimes, and silently swallow errors in the browser — making failures invisible to both users and monitoring. CWE-391 (Unchecked Error Condition) and CWE-755 (Improper Handling of Exceptional Conditions) both apply: async errors in event handlers and useEffect callbacks that lack try/catch or .catch() chains produce no user feedback and no diagnostic signal. ISO 25010 reliability.fault-tolerance requires that faults be contained — unguarded async paths let errors propagate with no containment boundary. This is especially acute in authentication and payment flows, where a silently failed async call leaves users in an ambiguous state.
Severity rationale
Critical because unguarded async errors in Node.js crash server processes and in browsers produce silent failures with no user feedback or diagnostic signal.
Remediation
Add a global safety net in your app entry point for any rejections that escape per-call handling, then add per-call try/catch in all async event handlers.
// In _app.tsx, main.tsx, or root layout.tsx (client component)
if (typeof window !== 'undefined') {
window.addEventListener('unhandledrejection', (event) => {
console.error('Unhandled rejection:', event.reason)
// Report to your error monitoring service here
})
}
For each async event handler, wrap the body:
async function handleSubmit() {
try {
await submitForm(data)
} catch (error) {
setErrorMessage('Submission failed. Please try again.')
reportError(error)
}
}
Verify by triggering a deliberate rejection in a development click handler and confirming it is caught rather than surfacing in the browser console unhandled.
DetectionPro
The detection method for this pattern is part of AuditBuffet Pro.
The full method (what to look for, pass and fail conditions, and how results get reported) ships inside the Error Handling Audit. The pattern definition, severity rationale, and remediation remain openly licensed under CC-BY-4.0.
External references
- cwe · CWE-755 — Improper Handling of Exceptional Conditions
- cwe · CWE-391 — Unchecked Error Condition
- iso-25010:2011 · reliability.fault-tolerance
Taxons
History
- 2026-04-18·v1.0.0·Initial import from saas-error-handling·automated