fix(ws): bound inbound frames synchronously and all-or-nothing
Two gaps in boundInbound, both from review of #117. The bound ran in an async pump reading the adapter's channel. `ws` emits a whole TCP read's worth of frames synchronously, so the unbounded channel took the burst before the pump saw the first frame: with maxWsQueue 2, a 2,000-frame burst reached the channel in full before close(1013). boundInbound now taps the channel through an internal, non-exported hook that runs inside push(), so each frame is bounded before it is queued. Measured on the Node listen() path, the same burst now closes on the 3rd frame. accept() also offered a frame to consumers in order and closed 1013 when a later queue was full, so the rejected frame had already reached earlier consumers. Capacity is now checked for every consumer before any delivery. Refs #107 Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>
This commit is contained in:
4 files changed
+96
-11
No files matched your search
@@ -1,4 +1,4 @@
|
||||
import { channel } from '../channel';
|
||||
import { channel, type Channel } from '../channel';
|
||||
import type { App } from '../app/types';
|
||||
import type { WsRequest, WsSocket } from './ws-core';
|
||||
import { nodeRequire } from '../node-require';
|
||||
@@ -91,7 +91,7 @@ export function eventSocket(host: EventfulSocket): WsSocket {
|
||||
*/
|
||||
export function neutralSocket(
|
||||
host: Pick<EventfulSocket, 'readyState' | 'send' | 'close'> & { terminate?(): void },
|
||||
inbound: ReturnType<typeof channel<unknown>>,
|
||||
inbound: Channel<unknown>,
|
||||
ac: AbortController,
|
||||
): WsSocket {
|
||||
return {
|
||||
|
||||
Reference in new issue
Block a user