You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Extend the silent-catch gate: promise-form handlers and literal false positives #213
Follow-ups from the #205 review of PR #210, both non-blocking there:
Promise-form silent catches stay ungated by design. The Silent catches: a bare catch{} swallows the error with no reason on record #205 gate covers the statement form only. The scanned sources carry ~198 .catch( handlers, some bare non-void swallows (e.g. core/src/host/diagnostics.js:222, :237, :246; core/src/host/store.js:454; core/src/host/agents.js:132-133). Decide the rule for the promise form — at minimum require a void prefix or a why-comment on a bare swallow — and extend check-empty-catch.mjs accordingly.
Literal false positives. The text catch {} inside a comment or a string literal of a scanned file trips the gate (fail-safe: over-flags, never misses). Stripping comments/strings before matching closes it.
Where it sits: .github/scripts/check-empty-catch.mjs; its test file carries the cases.
Suggested direction: take the two separately — the promise-form rule needs a decision on the idiom's status first; the literal hardening is mechanical.
Item 2 (literal false positives) is in #266: the gate blanks comments and the inside of strings, templates and regex literals before matching, so a catch {} written there is no longer reported. A } inside a string no longer cuts a block short either.
Item 1 (promise form) needs a decision before anyone codes it. There are about 51 bare non-void.catch(() => {} | undefined | null) calls in the shipped sources.
Proposed rule:
.catch(() => {}) whose result is dropped (a statement or an await statement) needs a void prefix or a why-comment.
.catch(() => undefined) / .catch(() => null) used as a value fallback (await x().catch(() => undefined) assigned or tested) stays allowed.
Expected once decided: check-empty-catch.mjs flags only the first form, and the existing sites get a void prefix or a one-line reason.
Activity
Birfy commentedon Oct 18, 2026
Item 2 (literal false positives) is in #266: the gate blanks comments and the inside of strings, templates and regex literals before matching, so a
catch {}written there is no longer reported. A}inside a string no longer cuts a block short either.Item 1 (promise form) needs a decision before anyone codes it. There are about 51 bare non-
void.catch(() => {} | undefined | null)calls in the shipped sources.Proposed rule:
.catch(() => {})whose result is dropped (a statement or anawaitstatement) needs avoidprefix or a why-comment..catch(() => undefined)/.catch(() => null)used as a value fallback (await x().catch(() => undefined)assigned or tested) stays allowed.Expected once decided:
check-empty-catch.mjsflags only the first form, and the existing sites get avoidprefix or a one-line reason.docs: note the discarded-catch rule in the four owning subsystem docs (…