@davoodmehraban89 / VELYQOR / commits / 75989cc
Fork 0

Intelligence, Advanced Charting & Trading Platform

fix(ws): cap per-socket send backlog and require REST reconciliation

davoodmehraban89 committed Oct 12, 2026 at 06:28 UTC 75989ccc20317672cc44bc0947bb844d531d130a
1 file changed +6
deploy/chartnova/market-stream-worker.mjs
+6
@@ -112,6 +112,12 @@ export class SymbolStreamRoom {
112 let delivered=0;
113 for(const socket of this.state.getWebSockets(symbol)){
114 if(socket.readyState!==1)continue;
115 + // Do not let a slow consumer hold an ever-growing outbound queue.
116 + // An affected client must reconnect and reconcile from REST.
117 + if(typeof socket.bufferedAmount==="number"&&socket.bufferedAmount>1_048_576){
118 + try{socket.close(1013,"slow consumer; REST recovery required")}catch{}
119 + continue;
120 + }
121 try{socket.send(data);delivered++}catch{try{socket.close(1011,"send error")}catch{}}
122 }
123 return respond({ok:true,symbol,sequence:seq,delivered});