Skip to content

fix: handle send errors when unsubscribing solana logs#1274

Merged
kaladinlight merged 1 commit into
developfrom
fix/solana-unsubscribe-error-handling
May 20, 2026
Merged

fix: handle send errors when unsubscribing solana logs#1274
kaladinlight merged 1 commit into
developfrom
fix/solana-unsubscribe-error-handling

Conversation

@kaladinlight
Copy link
Copy Markdown
Member

@kaladinlight kaladinlight commented May 20, 2026

Summary

  • Wraps the logsUnsubscribe send in unsubscribe() with a try/catch, matching the pattern already used in subscribeAddresses.
  • Prevents an unhandled exception (e.g. send on a non-OPEN socket) from crashing the solana coinstack.
  • No retry needed — the base AddressSubscriptionWebsocketClient auto-reconnects on close and replays subscriptions via onOpen, which calls subscribeAddresses(this.addresses). Stale subscription IDs on the old socket are abandoned with the old connection.

Test plan

  • Confirm solana websocket continues handling messages after a transient send failure during unsubscribe
  • Verify subscriptions are restored after a reconnect cycle

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes
    • Improved WebSocket subscription management with enhanced error handling and diagnostic logging to prevent unhandled exceptions.

Review Change Stack

Wraps the logsUnsubscribe send in a try/catch so a closed or non-OPEN
socket doesn't throw an unhandled exception and crash the coinstack.
The base class auto-reconnects and replays subscriptions via onOpen,
so no retry is needed here.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@kaladinlight kaladinlight requested a review from a team as a code owner May 20, 2026 16:35
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 20, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: e3b4b4d5-725f-4072-a00a-7e08b9800f74

📥 Commits

Reviewing files that changed from the base of the PR and between 61937de and 1a3fd7c.

📒 Files selected for processing (1)
  • node/coinstacks/solana/api/src/websocket.ts

📝 Walkthrough

Walkthrough

The PR adds error handling to the WebSocket unsubscribe method in the Solana API. The unsubscribe operation now wraps the JSON-RPC logsUnsubscribe send call in a try/catch block and logs a debug message with the subscription ID when sending fails, preventing unhandled exceptions.

Changes

Solana WebSocket Error Handling

Layer / File(s) Summary
WebSocket unsubscribe error handling
node/coinstacks/solana/api/src/websocket.ts
The unsubscribe(subscriptionId) method adds try/catch around the WebSocket send for logsUnsubscribe JSON-RPC requests and logs a debug message when the send operation fails.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~5 minutes

Poem

🐰 A little try, a little catch,
When sockets fail, we've got a match!
No unhandled throes shall pass this day,
Debug logs light the WebSocket way.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'fix: handle send errors when unsubscribing solana logs' directly and clearly describes the main change: adding error handling for send failures during Solana log unsubscription.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/solana-unsubscribe-error-handling

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.

@kaladinlight kaladinlight merged commit 451af39 into develop May 20, 2026
3 checks passed
@kaladinlight kaladinlight deleted the fix/solana-unsubscribe-error-handling branch May 20, 2026 16:53
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