Skip to content
Sarj Code Standards

no-silent-promise-catch

Disallow .catch() and second-argument .then() handlers that silently swallow a rejection; log, rethrow, or handle the error.

Why

A swallowed rejection hides failures and gives callers an indistinguishable fallback value.

Fix

Log, rethrow, or explicitly recover from the rejection; explain intentional teardown suppression.

Examples

Before — flagged Do not swallow the rejection
src/load.ts
load().catch(() => null);
After — preferred Report the rejection
src/load.ts
load().catch((error) => logger.error({ error }, "load failed"));
Before — flagged Report a rejection through a stable computed method
src/load.ts
const method = "catch";
Promise.reject(new Error("lost"))[method](() => null);
After — preferred Preserve a recognized optional body parse fallback
src/load.ts
const method = "json";
new Response("")[method]().catch(() => null);