Skip to content

fix: add error logging to empty catch blocks in cleanup operations - #18240

Closed
huaiyuWangh wants to merge 1 commit into
anomalyco:devfrom
huaiyuWangh:fix/empty-catch-blocks-error-logging
Closed

huaiyuWangh wants to merge 1 commit into
anomalyco:devfrom
huaiyuWangh:fix/empty-catch-blocks-error-logging

Conversation

@huaiyuWangh

@huaiyuWangh huaiyuWangh commented Mar 19, 2026 •

Copy link
Copy Markdown

Issue for this PR

Closes #18239

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

This PR fixes empty catch blocks in cleanup operations that were silently hiding errors.

The problem: Several catch blocks were empty, making it impossible to debug when cleanup operations failed (e.g., killing processes, destroying services).

The fix: Added debug-level logging to 4 empty catch blocks:

  • packages/opencode/src/mcp/index.ts - Log when killing MCP descendant processes fails
  • packages/opencode/src/pty/index.ts - Log when killing PTY processes fails (2 locations)
  • packages/opencode/src/server/mdns.ts - Log when destroying bonjour instance fails

Why it works: These are cleanup operations where failures are often expected (e.g., process already exited). The debug logs don't change the error handling behavior - errors are still gracefully ignored - but now developers can see what's happening during troubleshooting.

How did you verify your code works?

  • Verified the code compiles and type checks correctly
  • Confirmed log messages include relevant context (PIDs, error details)
  • These are debug-level logs, so they don't affect normal operation
  • The changes are simple additions with no behavioral changes to the error handling logic

Screenshots / recordings

Not applicable - this is a logging improvement with no UI changes.

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

@github-actions github-actions Bot added the needs:compliance This means the issue will auto-close after 2 hours. label Mar 19, 2026
@github-actions

Copy link
Copy Markdown
Contributor

The following comment was made by an LLM, it may be inaccurate:

@github-actions github-actions Bot removed the needs:compliance This means the issue will auto-close after 2 hours. label Mar 19, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Thanks for updating your PR! It now meets our contributing guidelines. 👍

@huaiyuWangh
huaiyuWangh force-pushed the fix/empty-catch-blocks-error-logging branch from 3a4e9e3 to f1ecc29 Compare March 19, 2026 12:54
Previously, several catch blocks silently ignored errors during cleanup
operations (killing processes, destroying services), which could hide
issues during development and debugging.

Changes:
- mcp/index.ts: Log when killing descendant MCP processes fails
- pty/index.ts: Log when killing PTY processes fails (2 locations)
- mdns.ts: Log when destroying bonjour instance fails

These are debug-level logs since failures during cleanup are often
expected (e.g., process already exited) but should still be visible
for troubleshooting.
@huaiyuWangh
huaiyuWangh force-pushed the fix/empty-catch-blocks-error-logging branch from f1ecc29 to 10550e8 Compare March 19, 2026 12:55
@github-actions github-actions Bot mentioned this pull request Apr 25, 2026
3 tasks done
@rekram1-node

Copy link
Copy Markdown
Collaborator

Automated PR Cleanup

Thank you for contributing to opencode.

Due to the high volume of PRs from users and AI agents, we periodically close older PRs using automated criteria so maintainers can focus review time on the most active and community-supported contributions.

This PR was closed because it matched the following cleanup criteria:

  • The PR was created more than 1 month ago
  • The PR had fewer than 2 positive reactions
  • Positive reactions are counted as thumbs-up, heart, celebration, or rocket reactions on the PR

PRs created within the last month are not affected by this cleanup.

If you believe this PR was closed incorrectly, or if you are still actively working on it, please leave a comment explaining why it should be reopened. A maintainer can review and reopen it if appropriate.

Thanks again for taking the time to contribute.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Empty catch blocks hide errors in cleanup operations

2 participants