Skip to content

[BUG] ~30 catch blocks silently swallow errors across core modules #24327

Closed as not planned

Description

@alfredocristofano

Description

Found ~30 instances of catch {} or catch { } in production code that suppress errors completely without any logging.

Most critical locations:

  • auth/index.ts:62 — JSON.parse of OPENCODE_AUTH_CONTENT fails silently, causing auth to be silently absent
  • session/message-v2.ts:1191 — stream error JSON parse fails silently
  • session/session.ts:508 — session remove() catches error but lets it succeed anyway
  • lsp/client.ts:150 — server stderr at debug level (startup errors invisible by default)
  • pty/index.ts:125 — process kill/close failures could create zombie processes
  • mcp/index.ts:524 — SIGTERM failures not reported
  • global/index.ts:54 — cache directory cleanup failure not logged
  • provider/error.ts:71 — JSON parse errors in response handling not logged
  • util/filesystem.ts — statSync, realpathSync, glob scan failures not logged
  • util/error.ts:11 — JSON.stringify failure not logged

Also session/llm.ts:258 uses catch (e: any) instead of catch (e: unknown).

Reproduction steps

  1. Search for catch {} or catch { } in packages/opencode/src/
  2. Observe that no logging occurs within these blocks
  3. Errors that cause failures in these paths are silently lost

Environment info

  • OS: all platforms
  • Bun version: 1.3.x
  • OpenCode version: current dev branch

Activity

  1. added
    coreAnything pertaining to core functionality of the application (opencode server stuff)
    on Apr 25, 2026
  2. github-actions commented on Apr 25, 2026

    @github-actions
    Contributor

    This issue doesn't fully meet our contributing guidelines.

    What needs to be fixed:

    • No issue template was used. Please use one of the three required templates: Bug Report, Feature Request (title must start with [FEATURE]:), or Question. The current title uses a fix: prefix which is a PR convention, not an issue template format.

    Please edit this issue to address the above within 2 hours, or it will be automatically closed.


    This issue might be a duplicate of existing issues. Please check:

    If you believe this was flagged incorrectly, please let a maintainer know.

  3. changed the title [-]fix: ~30 catch blocks silently swallow errors across core modules[/-] [+][BUG] ~30 catch blocks silently swallow errors across core modules[/+] on Apr 25, 2026
  4. github-actions commented on Apr 25, 2026

    @github-actions
    Contributor

    Thanks for updating the issue! It now follows the contributing guidelines with a clear description, specific code locations, reproduction steps, and environment info. The needs:compliance label has been removed.

  5. alfredocristofano commented on Apr 26, 2026

    @alfredocristofano
    Author

    Update: after inspecting the current dev branch, most of the silent catch blocks listed in this issue have already been fixed in prior commits:

    • auth/index.ts:65 — already has log.warn() ✅
    • message-v2.ts:1195 — already has log.debug() ✅
    • util/error.ts:15 — already has log.debug() ✅
    • global/index.ts:57 — already has log.warn() ✅
    • session/session.ts:508 — already has log.warn() + log.error() ✅

    The only remaining truly empty catch {} in the entire packages/opencode/src tree was in cli/cmd/tui/component/dialog-workspace-create.tsx:146. I've opened PR #24502 to fix that one.

    Given that the core issues are already resolved, this issue could be closed or kept open until #24502 is merged.

  6. alfredocristofano commented on Apr 27, 2026

    @alfredocristofano
    Author

    Re-checking current dev, this is still open work. There are still empty catch {} blocks and a couple of catch (e: any) sites in packages/opencode/src.

    The linked PRs have not landed yet, and a few of them are dirty/conflicting. I’d keep this issue open until there is a clean fix in dev.

  7. alfredocristofano commented on Apr 27, 2026

    @alfredocristofano
    Author

    Update: I cleaned up #24331 and force-pushed it onto current dev. The diff is now 10 files and no longer includes the unrelated import/barrel changes.

    I also closed #24502, #24503, and #24504 because those branches had picked up large unrelated diffs and conflicts. Keeping #24331 as the cleaner path for this issue.

  8. removed
    coreAnything pertaining to core functionality of the application (opencode server stuff)
    on May 3, 2026
  9. github-actions commented on Jul 4, 2026

    @github-actions
    Contributor

    To stay organized issues are automatically closed after 60 days of no activity. If the issue is still relevant please open a new one.

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

Metadata

Metadata

Assignees

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