Skip to content

fix: properly stop event processing when indexer.stop() is called (SS2-145)#67

Merged
metalboyrick merged 2 commits into
mainfrom
fix/indexer-stop-event-handling
Jan 20, 2026
Merged

fix: properly stop event processing when indexer.stop() is called (SS2-145)#67
metalboyrick merged 2 commits into
mainfrom
fix/indexer-stop-event-handling

Conversation

@metalboyrick
Copy link
Copy Markdown
Collaborator

@metalboyrick metalboyrick commented Jan 13, 2026

Description of change

Previously, calling indexer.stop() would not properly stop the onEvent handlers from processing new blocks. This was because:

  1. The WebSocket subscription was never unsubscribed
  2. The WebSocket connection was never disconnected
  3. In-flight event handlers could still run after stop() was called

This fix:

  • Adds early return in subscription handler when indexer is stopped
  • Unsubscribes from newHeads subscription before closing connections
  • Gracefully handles "Invalid subscription id" errors (code 66)
  • Disconnects WebSocket connection to prevent reconnection attempts

Issue number

Closes #54

Type of change (delete irrelevant types)

  • Bug fix (non-breaking change which fixes an issue)

Checklist:

  • I have tested locally and linked a screen recording with this PR
  • I have adhered to clean code conventions
  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • I have added tests that prove my fix is effective or that my feature works

Previously, calling indexer.stop() would not properly stop the onEvent
handlers from processing new blocks. This was because:

1. The WebSocket subscription was never unsubscribed
2. The WebSocket connection was never disconnected
3. In-flight event handlers could still run after stop() was called

This fix:

- Adds early return in subscription handler when indexer is stopped
- Unsubscribes from newHeads subscription before closing connections
- Gracefully handles "Invalid subscription id" errors (code 66)
- Disconnects WebSocket connection to prevent reconnection attempts

Closes #54

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@metalboyrick metalboyrick changed the title fix: properly stop event processing when indexer.stop() is called fix: properly stop event processing when indexer.stop() is called (SS2-145) Jan 13, 2026
Copy link
Copy Markdown
Collaborator

@BaoHG1508 BaoHG1508 left a comment

Choose a reason for hiding this comment

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

LGTM

@metalboyrick metalboyrick merged commit a77893d into main Jan 20, 2026
5 checks passed
@metalboyrick metalboyrick deleted the fix/indexer-stop-event-handling branch January 20, 2026 03:59
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.

Indexer is stopped but onEvent still picks up events from the indexer.

2 participants