fix(relay): keep bulk streaming from blocking client requests
Negotiate downstream delivery credit and schedule response streams fairly before encryption. Bound queued output, preserve deltas and WebSocket close ordering, and retain legacy peer compatibility. Validated with 81 relay tests, workspace type-check and lint, web build and mobile assets, and slow-link tests through the production relay. Confirmed on LTE by the maintainer.
This commit is contained in:
@@ -34,6 +34,7 @@ export const TunnelFrameType = {
|
||||
WsClose: 10,
|
||||
Ping: 11,
|
||||
Pong: 12,
|
||||
DeliveryAck: 13,
|
||||
};
|
||||
|
||||
const TUNNEL_FRAME_TYPE_VALUES = new Set(Object.values(TunnelFrameType));
|
||||
@@ -43,6 +44,14 @@ export const isTunnelFrameType = (value) => TUNNEL_FRAME_TYPE_VALUES.has(value);
|
||||
|
||||
const MAX_STREAM_ID = 0xffffffff;
|
||||
|
||||
/** Decode the client's cumulative raw tunnel-frame byte count. */
|
||||
export const decodeDeliveryAck = (payload) => {
|
||||
if (payload.length !== 8) throw new Error('invalid delivery acknowledgement');
|
||||
const bytes = Number(new DataView(payload.buffer, payload.byteOffset, payload.byteLength).getBigUint64(0));
|
||||
if (!Number.isSafeInteger(bytes)) throw new Error('invalid delivery acknowledgement');
|
||||
return bytes;
|
||||
};
|
||||
|
||||
export class TunnelCodecError extends Error {
|
||||
constructor(message) {
|
||||
super(message);
|
||||
|
||||
Reference in New Issue
Block a user