feat: WebSocket enhancements with request queue and dynamic subscription management#1
Open
degenRobot wants to merge 3 commits intomainfrom
Open
feat: WebSocket enhancements with request queue and dynamic subscription management#1degenRobot wants to merge 3 commits intomainfrom
degenRobot wants to merge 3 commits intomainfrom
Conversation
Implement WebSocket connection resilience and monitoring features: ## Exponential Backoff - Replace fixed reconnection delays with exponential backoff (2s → 4s → 8s → 16s → 30s cap) - Prevent server overwhelming during outages - Maintain default 5 reconnection attempts ## Connection Status Tracking - Add ConnectionStateManager for real-time connection monitoring - Track connection status: connecting, connected, disconnected, error - Collect connection statistics: uptime, reconnect attempts, total connections - Emit status change events for reactive UI updates ## Client API Enhancements - Add connection actions to PublicShredClient and PublicSyncClient - New methods: getConnectionStatus(), getConnectionStats(), isConnected() - Subscribe to connection changes with onConnectionChange() - Async waitForConnection() with configurable timeout ## Developer Experience - Full backward compatibility - existing code works unchanged - TypeScript support with proper type definitions - Comprehensive test coverage (28 new tests) - Live examples for reconnection and connection monitoring - Updated README with usage documentation All changes are non-breaking with sensible defaults. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
Implements comprehensive WebSocket request management with: - Request queue with priority handling and retry logic - Dynamic subscription management for efficient event streaming - Connection-aware processing with automatic pause/resume - Extensive test coverage and example implementations Key features: - Priority-based request queuing (high/normal/low) - Configurable retry policies with exponential backoff - Dynamic subscription updates without reconnection - Request batching and processing statistics - Memory-efficient event buffering This enhancement improves reliability and performance for WebSocket-based operations, particularly beneficial for high-throughput scenarios. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
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.
Description:
Summary
Key Features
Request Queue Management
Dynamic Subscription Management
Connection Enhancements
Backwards Compatibility
✅ Fully backwards compatible - All existing APIs remain unchanged:
watchShreds,watchShredEvent, andwatchContractShredEventfunctions work as beforetests/integration/backward-compatibility.test.tsTesting
Extensive test coverage added:
Examples
Added 13 new example files demonstrating:
examples/request-queue.ts)examples/dynamic-subscription.ts)examples/connection-monitoring.ts)examples/reconnection-test.ts)Performance Improvements
Documentation
Updated README with:
This PR significantly enhances the reliability and performance of WebSocket operations while maintaining full backward compatibility
with existing implementations.