Skip to content

Empty catch blocks silently swallow errors in config and initialization #11701

Closed

Description

@ryan-mt

Summary

Several empty catch blocks in the codebase silently swallow errors, making debugging difficult and hiding potential issues from users.

Locations

  1. packages/opencode/src/config/config.ts:1235 - Plugin resolution errors swallowed
  2. packages/opencode/src/global/index.ts:53 - Initialization errors swallowed
  3. Multiple locations in file operations

Issue

1. Config plugin resolution (config.ts:1235)

for (let i = 0; i < data.plugin.length; i++) {
  const plugin = data.plugin[i]
  try {
    data.plugin[i] = import.meta.resolve!(plugin, configFilepath)
  } catch (err) {}  // Error completely swallowed - user has no idea plugin failed
}

2. Global initialization (global/index.ts:53)

try {
  const contents = await fs.readdir(Global.Path.cache)
  await Promise.all(
    contents.map((item) => fs.rm(path.join(Global.Path.cache, item), {...})),
  )
} catch (e) {}  // Cache cleanup failure hidden

Impact

  • Severity: Low-Medium
  • Type: Error Handling / Debugging
  • Effect:
    • Invalid plugins silently ignored, user sees no feedback
    • Initialization issues hidden
    • Makes troubleshooting difficult

Suggested Fix

Replace empty catch blocks with proper logging:

// config.ts
try {
  data.plugin[i] = import.meta.resolve!(plugin, configFilepath)
} catch (err) {
  log.warn("failed to resolve plugin", { plugin, error: err })
  // Optionally remove the invalid plugin from the array
}

// global/index.ts
try {
  // ...cache cleanup
} catch (e) {
  log.warn("failed to clear cache", { error: e })
}

Activity

  1. github-actions commented on Feb 2, 2026

    @github-actions
    Contributor

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

    These issues also address error handling gaps in the codebase that result in silent failures or crashes when errors aren't properly handled. You may want to review these related error handling issues to ensure a comprehensive solution across all affected modules.

  2. github-actions commented on Apr 3, 2026

    @github-actions
    Contributor

    To stay organized issues are automatically closed after 90 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