Skip to content

fix: add error logging to all silent catch blocks#185

Merged
ChrisRomp merged 2 commits intomainfrom
fix/error-logging-178
Apr 2, 2026
Merged

fix: add error logging to all silent catch blocks#185
ChrisRomp merged 2 commits intomainfrom
fix/error-logging-178

Conversation

@ChrisRomp
Copy link
Copy Markdown
Owner

Summary

Add error logging to all silent catch blocks across the codebase, ensuring no errors are silently swallowed.

What it does

  • Adds logging to every previously-silent catch {} block in session-manager.ts and index.ts
  • Creates a safeDestroySession() helper to DRY 8 identical destroy-and-ignore patterns
  • Differentiates log levels: log.warn for user-visible failures, log.debug for best-effort operations
  • Suppresses ENOENT in parseEnvFile (expected when no .env exists) while logging other errors

Key changes

  • src/core/session-manager.ts: 6 HIGH catches (warn), 8 destroySession catches (safeDestroySession helper), 14 MEDIUM/LOW catches (debug/warn)
  • src/index.ts: 2 HIGH catches (warn), 10 MEDIUM/LOW catches (debug)
  • src/core/error-logging.test.ts: 3 new tests for parseEnvFile error handling

Scope

  • Zero silent catch blocks remain in session-manager.ts and index.ts
  • No behavioral changes: all control flow is identical, only logging is added
  • 683 tests pass (3 new)

Fixes #178

HIGH (6): Add log.warn to user-visible silent failures:
- getModelInfo, readPlan, deletePlan, getAuthStatus in session-manager
- Mid-turn and command listModels in index.ts

 destroySession (8): Create safeDestroySession() helper withMEDIUM
log.debug, replacing 8 identical silent catch blocks

 misc (11): Add log.debug/warn to:MEDIUM
- listModels fire-and-forget (context cache, fallback, plan summarization)
- getSessionMode fallbacks
- Skill toggle RPCs
- .env parse (ENOENT suppressed, other errors warned)
- Config reload notification, cancelStream, plan surfacing

LOW (12): Add log.debug to remaining best-effort catches:
- Temp file cleanup, setTyping, addReaction
- FS directory walks (MCP plugins, skill discovery)
- SKILL.md reads, realpathSync, git diff in tool handlers

Zero silent catch blocks remain in session-manager.ts and index.ts.

Tests: 3 new tests for parseEnvFile error/ENOENT handling (683 total)

Fixes #178

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings April 2, 2026 21:33
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds structured logging to previously-silent error-handling paths so operational failures are visible instead of being swallowed.

Changes:

  • Added log.debug / log.warn logging to many previously empty catch {} and .catch(() => {}) call sites in src/index.ts and src/core/session-manager.ts.
  • Introduced SessionManager.safeDestroySession() to de-duplicate best-effort destroySession() cleanup with logging.
  • Updated parseEnvFile() to suppress expected ENOENT while logging other parse/read failures, plus added focused Vitest coverage.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

File Description
src/index.ts Replaces multiple silent best-effort catches with debug/warn logging in runtime paths (message handling, scheduler, cleanup).
src/core/session-manager.ts Adds logging to previously swallowed exceptions, introduces safeDestroySession(), and improves .env parsing error visibility (with ENOENT suppression).
src/core/error-logging.test.ts Adds tests verifying .env parsing logs on non-ENOENT and stays quiet on ENOENT.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/index.ts
Comment thread src/core/error-logging.test.ts Outdated
Comment thread src/core/error-logging.test.ts Outdated
- Add logging to lock chain .catch() patterns (eventLocks, channelLocks)
- Add logging to surfacePlanIfExists promise catch
- Remove unused afterEach import in tests
- Use os.tmpdir() for ENOENT test instead of hardcoded /tmp path

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@ChrisRomp ChrisRomp merged commit f907865 into main Apr 2, 2026
6 checks passed
@ChrisRomp ChrisRomp deleted the fix/error-logging-178 branch April 2, 2026 22:14
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.

Bug: SDK errors silently swallowed, not logged by bridge

2 participants