feat(sdk): resilient reconnecting WebSocket signals client (#45) - #61
Merged
Merged
Conversation
…sh & deduplication
- Kept main's CommonJS/ts-jest tsconfig (already proven with nirium-protocol#53's tests) instead of this branch's NodeNext config, to avoid destabilizing what's already merged. - Dropped an unused `viem` dependency this branch had added (Ethereum library, never referenced anywhere in resilient-ws.ts) — same class of leftover already caught and removed in PR nirium-protocol#58. - test/ws-resilient.test.ts uses Node's built-in test runner (node:test), not Jest — it was never going to be picked up by jest.config.js's `roots: ['<rootDir>/src']` regardless of this merge. Wired it into `npm test` via `node --experimental-strip-types --test test/*.test.ts` so it actually runs going forward instead of silently never executing.
This was referenced Aug 26, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Resilient Reconnecting WebSocket Signals Client & Example (#45)
Overview
This PR implements
ResilientSignalClientin@nirium/sdk(exported asResilientSignalClient) to handle WebSocket signal stream connectivity with automatic exponential backoff, token refresh hooks, heartbeat ping/pong keepalives, and burst signal deduplication. It also adds a runnable example project inexamples/ws-signals-resilient/.Summary of Changes
SDK Class (
packages/sdk/src/resilient-ws.ts&packages/sdk/src/index.ts):ResilientSignalClient: Auto-reconnecting WebSocket client with exponential backoff and random jitter (initialBackoffMsdefaulting to 1000ms up tomaxBackoffMsdefaulting to 30000ms).onTokenRefresh): Executes before establishing reconnect attempts to automatically update JWT auth headers/queries.{ type: 'ping' }frames (or native WS ping frames) everypingIntervalMsand detects lost connectivity if no pong arrives within twice the ping interval.dedupWindowMs(60s default) to handle network bursts and redundant transmissions cleanly.onStatus,onSignal, andonErrorevent handling with graceful teardown (close()).Automated Unit Tests (
packages/sdk/test/ws-resilient.test.ts):Runnable Example Project (
examples/ws-signals-resilient/):index.ts) formatting signals and rendering real-time connection status transitions (connecting,connected,reconnecting,disconnected).test/smoke.test.js) and documentation (README.md).Verification
node --experimental-strip-types --test test/ws-resilient.test.ts.npm testinexamples/ws-signals-resilient.