Why promise rejections are dangerous

A rejected promise that isn't caught fails silently. In older Node versions it would crash the process. In browsers, it logs a warning but doesn't trigger error boundaries or monitoring — unless you specifically listen for it.

The three types of promise failures

  1. Explicit rejection: Promise.reject(new Error(...))
  2. Thrown error in async function: async function foo() { throw new Error() }
  3. Failed await: const data = await fetch(url) where fetch throws

How to track them

ProdFix listens for the window unhandledrejection event and automatically captures all unhandled promise rejections with full stack traces. You see these in your error dashboard alongside regular exceptions.

The fix patterns

// Bad: unhandled rejection
fetchUser(id).then(setUser);

// Good: handled
fetchUser(id)
  .then(setUser)
  .catch(err => {
    setError(err.message);
    trackError(err); // optional manual tracking
  });

// Better: async/await with try/catch
try {
  const user = await fetchUser(id);
  setUser(user);
} catch (err) {
  setError(err.message);
}

The global handler

As a backstop, add a global unhandledrejection listener that logs to your error monitoring. ProdFix does this automatically when you install the SDK.

Stop flying blind in production.

ProdFix gives you error monitoring, performance tracking, security alerts, and AI-powered fixes — built for solo founders and vibe coders. One SDK, 2-minute setup.

Free tier · 3 projects · MCP for Cursor + Claude Code