Skip to content

fix: implement WebSocket backpressure buffering at 150ms intervals#226

Open
binayyub4211 wants to merge 2 commits into
StellarFlow-Network:mainfrom
binayyub4211:perf/websocket-backpressure
Open

fix: implement WebSocket backpressure buffering at 150ms intervals#226
binayyub4211 wants to merge 2 commits into
StellarFlow-Network:mainfrom
binayyub4211:perf/websocket-backpressure

Conversation

@binayyub4211
Copy link
Copy Markdown

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.

@drips-wave
Copy link
Copy Markdown

drips-wave Bot commented May 29, 2026

@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! 🚀

Learn more about application limits

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.

📡 Perf | WebSocket Backpressure Buffering

1 participant