Skip to content

Silent catches: a bare catch{} swallows the error with no reason on record #205

Closed

Description

@hsliuustc0106

What

Shipped sources contain catch clauses whose block is completely empty — no statement, no comment, no named error. The failure is swallowed and nothing on record says why that is safe. Today:

  • core/src/host/diagnostics.js:108, core/src/host/diagnostics.js:110 (version probing)
  • core/src/host/hooks.js:819 (cancelling a mentioned session)
  • core/src/host/home-lock.js:53, :83, :92 (lock touch / unlink races)
  • core/src/client/index.js:50 (providing the client flybot service)
  • core/src/client/flybot-registry.js:99 (change polling)
  • plugins/social/index.js:35, :37; plugins/social/client.js:900; plugins/social/src/social.js:297, :392, :1100; plugins/social/src/mcp-client.js:148

Actual behavior

Nothing distinguishes "the error cannot matter here" from "nobody looked". The oxlint config (no-undef, no-unused-vars) gates nothing about this, so nothing stops the next silent catch from landing.

Expected behavior

A catch that swallows an error says why — at minimum a comment in the block naming the reason (racing unlink, best-effort refresh, retry on next poll), and a named binding whenever the handler could act on the error. A repo check fails the build on a bare catch, the way plugin-imports fails the build on an out-of-package import.

Where it sits

The list above; the natural gate home is .github/scripts/ + its .test.mjs, which the package job of tests-ok and root npm run verify already run — no workflow change needed.

Suggested direction (for discussion, not prescriptive)

  1. Add .github/scripts/check-empty-catch.mjs: scan core/src/**, core/index.js, core/web-search.js, plugins/*/src/**, plugins/*/index.js, plugins/*/client.js; flag a catch clause (statement form — the .catch(() => {}) promise form is a separate, deliberate void idiom and stays out of scope) whose block holds neither a statement nor a comment. Test helpers under test/ stay out of scope.
  2. Annotate each bare catch above with the truthful reason.
  3. Record the rule in docs/code-standards.md.

Not user-visible: no changelog fragment.

Reliability angle: the README promises a Bot's results can be checked; a swallowed error is exactly where that breaks silently.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions