# No console.error in production without boundary

- **Pattern:** `ab-002298` (`saas-error-handling.graceful-degradation.no-console-error-without-boundary`)
- **Severity:** low
- **Lifecycle:** active
- **Last modified:** 2026-04-18
- **Canonical URL:** https://auditbuffet.com/patterns/ab-002298
- **License:** CC-BY-4.0 — attribute to AuditBuffet Pattern Catalog (https://auditbuffet.com/patterns/ab-002298)

## Why it matters

A catch block that contains only `console.error()` and no further action is functionally equivalent to swallowing the error in production. CWE-778 (Insufficient Logging) applies when logging goes only to a console that no one monitors in real time. CWE-391 (Unchecked Error Condition) applies when the error is recorded but not acted upon — no user feedback, no monitoring service capture. ISO 25010 reliability.fault-tolerance requires that error conditions trigger corrective action, not just log output. Most hosted Node.js environments (Vercel, Railway, Fly.io) don't surface raw `console.error` output to developers in real time, making bare-console error handling invisible in practice.

## Severity rationale

Low because `console.error`-only catch blocks produce a log record but no user feedback and no monitoring alert, making errors practically invisible in production hosting environments.

## Remediation

Replace bare `console.error` catch blocks with handling that notifies both the user and the monitoring service.

```ts
// Before — error disappears in production
} catch (error) {
  console.error('Failed to fetch user:', error)
}

// After — error is visible to monitoring and the user
} catch (error) {
  console.error('Failed to fetch user:', error) // keep for local dev context
  Sentry.captureException(error, { extra: { context: 'fetchUser' } })
  setError('Unable to load your profile. Please refresh.')
}
```

Search the codebase for `console.error` inside catch blocks using your IDE's symbol search and audit each one: if there is no `captureException` call and no state update in the same block, it needs both additions.

## Detection

**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](https://auditbuffet.com/audits/saas-error-handling). The pattern definition, severity rationale, and remediation remain openly licensed under CC-BY-4.0.

## External references

- cwe CWE-778
- cwe CWE-391
- iso-25010 reliability.fault-tolerance

Taxons: error-resilience, observability

HTML version: https://auditbuffet.com/patterns/ab-002298
