feat(onebot): make the websocket frame cap configurable and diagnosable (#631)
- expose DEFAULT_MAX_PAYLOAD_BYTES; an inbound frame over the cap now reports its declared byte size, message type and the effective limit, recovered by walking the buffered frame stream so the number is right when a chunk carries several frames, the oversized header spans chunks, or control frames are interleaved; when the walk cannot reach a verdict the error names the cap without a size - truncate close reasons to the RFC 6455 control-frame room on a UTF-8 boundary (an over-long reason previously produced an invalid control frame) - add optional maxPayloadBytes (default 100 MiB unchanged) to the three adapters that read WebSocket frames: wsServers, wsClients and httpServers with enableWebSocket. httpClients rejects the field because it has no WebSocket transport, and the value is part of the binding signature so a change rebinds the transport instead of being saved without taking effect - keep the existing 1009 log lines and append the actionable hint instead of replacing the template - WebUI field (including httpServers once the embedded listener is on) and README docs for the 100 MiB => ~445 s (7:26) inline PCM consequence
This commit is contained in:
1 parent
bd40ac3522
commit
8d9f44b6b0
16 files changed
+1035
-77
No files matched your search
@@ -1033,7 +1033,9 @@ describe('WebSocketClient', () => {
|
||||
),
|
||||
);
|
||||
const err = await events.waitError();
|
||||
expect(err.message).toBe('WebSocket protocol error: Payload exceeds configured max');
|
||||
expect(err.message).toBe(
|
||||
'WebSocket protocol error: Payload exceeds configured max: 5 B text frame exceeds the 4 byte limit (maxPayloadBytes)',
|
||||
);
|
||||
expect((err as Error & { code?: number }).code).toBe(1009);
|
||||
});
|
||||
|
||||
|
||||
Reference in new issue
Block a user