HH-415: restore binary payload byte semantics

Co-authored-by: multica-agent <github@multica.ai>
This commit is contained in:
2026-08-21 14:54:56 +08:00
co-authored by multica-agent
parent aa48fd6943
commit 78d116c8eb
3 changed files with 9 additions and 9 deletions
+6 -6
View File
@@ -601,10 +601,10 @@ export function eventCollector(sessionId, targetId, {
case "Network.webSocketFrameReceived": {
const direction = method.endsWith("Sent") ? "sent" : "received";
mark(`ws_${direction}`);
const payloadBytes = Buffer.byteLength(params.response.payloadData);
const decodedPayloadBytes = params.response.opcode === 2
const encodedPayloadBytes = Buffer.byteLength(params.response.payloadData);
const payloadBytes = params.response.opcode === 2
? Buffer.from(params.response.payloadData, "base64").length
: payloadBytes;
: encodedPayloadBytes;
let state = webSocketLimits.get(requestId);
if (!state) {
state = { window: null, windowEvents: 0, emitted: 0 };
@@ -617,11 +617,11 @@ export function eventCollector(sessionId, targetId, {
}
state.windowEvents++;
let dropReason;
if (decodedPayloadBytes > maxWebSocketFrameBytes) dropReason = "frame_size_limit";
if (payloadBytes > maxWebSocketFrameBytes) dropReason = "frame_size_limit";
else if (state.windowEvents > maxWebSocketEventsPerSecond) dropReason = "rate_limit";
else if (state.emitted >= maxWebSocketEventsPerConnection) dropReason = "event_limit";
if (dropReason) {
dropWebSocketFrame(requestId, dropReason, decodedPayloadBytes);
dropWebSocketFrame(requestId, dropReason, payloadBytes);
break;
}
state.emitted++;
@@ -630,7 +630,7 @@ export function eventCollector(sessionId, targetId, {
direction,
opcode: params.response.opcode,
payload_bytes: payloadBytes,
...(params.response.opcode === 2 && { decoded_payload_bytes: decodedPayloadBytes }),
...(params.response.opcode === 2 && { encoded_payload_bytes: encodedPayloadBytes }),
payload: { state: "omitted", reason: "frame_policy" },
});
break;