Skip to content

Comments

Log evicted WebSocket close errors instead of silently swallowing#800

Merged
dsarno merged 1 commit intobetafrom
fix/issue-795-coderabbit-followup
Feb 20, 2026
Merged

Log evicted WebSocket close errors instead of silently swallowing#800
dsarno merged 1 commit intobetafrom
fix/issue-795-coderabbit-followup

Conversation

@dsarno
Copy link
Collaborator

@dsarno dsarno commented Feb 20, 2026

Follow-up to #798 — addresses CodeRabbit review suggestion to log the swallowed exception in _evict_connection when closing a stale WebSocket, matching the pattern used in _ping_loop.

Generated with Claude Code

Summary by Sourcery

Enhancements:

  • Add debug-level logging for exceptions raised while closing stale WebSocket connections during eviction.

Summary by CodeRabbit

  • Bug Fixes
    • Enhanced error reporting for WebSocket connection closure operations, enabling better visibility into connection termination issues for system diagnostics and troubleshooting.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@sourcery-ai
Copy link
Contributor

sourcery-ai bot commented Feb 20, 2026

Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Logs exceptions raised when closing evicted WebSocket connections instead of silently swallowing them, to aid debugging of stale connection cleanup.

Sequence diagram for WebSocket eviction with error logging

sequenceDiagram
    participant PluginHub
    participant WebSocket
    participant Logger

    PluginHub->>PluginHub: _evict_connection(session_id, reason)
    PluginHub->>WebSocket: close(code=1001)
    alt close succeeds
        WebSocket-->>PluginHub: closed
    else close raises exception
        WebSocket-->>PluginHub: Exception close_ex
        PluginHub->>Logger: debug("Error closing evicted WebSocket for session %s: %s", session_id, close_ex)
    end
Loading

File-Level Changes

Change Details Files
Log exceptions that occur while closing evicted WebSocket connections during stale-session eviction.
  • Wrap WebSocket close call in try/except that captures the exception as a variable
  • Emit a debug-level log message when the WebSocket close operation raises an exception, including session id and error details
  • Remove the previous bare except block that silently swallowed close errors
Server/src/transport/plugin_hub.py

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 20, 2026

Caution

Review failed

The pull request is closed.

📝 Walkthrough

Walkthrough

The _evict_connection method in plugin_hub.py now captures and logs exceptions when closing an evicted WebSocket instead of silently suppressing them. The exception is recorded with the session ID for improved observability while maintaining the original control flow.

Changes

Cohort / File(s) Summary
WebSocket Close Error Handling
Server/src/transport/plugin_hub.py
Enhanced exception handling in _evict_connection to capture and log close operation failures with session context instead of silent suppression.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~5 minutes

Poem

🐰 A whisper caught, a log now told,
Where silence once did softly hold,
The WebSocket's farewell, now we see,
With session trails for you and me!
Error witnessed, not erased away,
Better debugging comes today! 📝

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/issue-795-coderabbit-followup

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey - I've left some high level feedback:

  • Consider logging the exception with exc_info=True (e.g., logger.debug("Error closing evicted WebSocket for session %s", session_id, exc_info=True)) so you retain the full traceback rather than just the stringified exception.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- Consider logging the exception with `exc_info=True` (e.g., `logger.debug("Error closing evicted WebSocket for session %s", session_id, exc_info=True)`) so you retain the full traceback rather than just the stringified exception.

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@dsarno dsarno merged commit 2487100 into beta Feb 20, 2026
2 of 3 checks passed
@dsarno dsarno deleted the fix/issue-795-coderabbit-followup branch February 20, 2026 22:22
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.

1 participant