Skip to content

fix(har): off-by-one in WebSocket frame header size calculation #41142

@yen0304

Description

@yen0304

Describe the bug

In harTracer.ts, the WebSocket frame header size calculation uses length > 2 ** 16 to determine when to use the 64-bit extended payload length field. Per RFC 6455 Section 5.2, a 16-bit unsigned integer can represent values 0–65535, so a payload of exactly 65536 (2 ** 16) bytes cannot fit in 16 bits and requires the 64-bit extended length field (8 additional bytes). The current condition misses this boundary, causing response._transferSize to be 6 bytes too small for payloads of exactly 65536 bytes.

Steps to reproduce

Record HAR for a WebSocket connection that receives a frame with exactly 65536 bytes of payload data. The reported response._transferSize will be 6 bytes less than the actual on-wire size.

Expected behavior

The condition should be length >= 2 ** 16 instead of length > 2 ** 16.

Introduced in

Commit 426cc4e ("feat(har): calculate request.headerSize, response.headerSize, and response._transferSize for WebSocket")

Metadata

Metadata

Assignees

Labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions