fix: implement WebSocket backpressure buffering at 150ms intervals#226
Open
binayyub4211 wants to merge 2 commits into
Open
fix: implement WebSocket backpressure buffering at 150ms intervals#226binayyub4211 wants to merge 2 commits into
binayyub4211 wants to merge 2 commits into
Conversation
|
@binayyub4211 Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
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.
Closes #161
PR Title
fix: implement WebSocket backpressure buffering at 150ms intervals
PR Description
What was done
Added an array ref bufferRef in useSocket.ts to collect incoming telemetry and price updates from the WebSocket connection.
Implemented a steady useEffect interval running every 150ms. On each tick, if the buffer has items, we clone and empty it, and apply all pending updates chronologically to the lastUpdate state within a single functional state updater.
Updated the WebSocket onmessage handler to push incoming updates directly into the array buffer instead of invoking the React state updater immediately.
Cleared the buffer on disconnects and reconnects to prevent stale telemetry updates from being applied.
Why it was done
High-frequency telemetry updates during load surges caused back-to-back React renders and UI thread locks, degrading dashboard responsiveness.
Buffering and batching updates at a steady 150ms interval maintains UI responsiveness and provides smooth rendering metrics while preserving the completeness of all telemetry logs.
How it was verified
Verified hook state transitions, type soundness, and React effect dependencies statically.
Ensured chronological delta accumulation operates correctly within a single state update.
Note: Local environment builds and package installation were skipped due to environment-specific timeout constraints.