fix(har): off-by-one in WebSocket frame header size calculation#41143
Open
yen0304 wants to merge 1 commit into
Open
fix(har): off-by-one in WebSocket frame header size calculation#41143yen0304 wants to merge 1 commit into
yen0304 wants to merge 1 commit into
Conversation
A payload of exactly 65536 (2**16) bytes cannot fit in a 16-bit unsigned integer and requires the 64-bit extended payload length field per RFC 6455 Section 5.2. The previous condition `length > 2 ** 16` missed this boundary, causing `response._transferSize` to be 6 bytes too small.
dcrousso
approved these changes
Jun 4, 2026
| it('should use 64-bit extended length for exactly 2**16 byte websocket payload', async ({ contextFactory, server }, testInfo) => { | ||
| // RFC 6455 Section 5.2: 16-bit extended length covers 126-65535. | ||
| // Payloads of exactly 65536 (2**16) bytes require the 64-bit extended length field. | ||
| const incoming = 'x'.repeat(2 ** 16); |
Contributor
There was a problem hiding this comment.
rather than adding an entirely new test for this, lets just update the test right above
-const incoming = 'x'.repeat(2 ** 16 + 1);
+const incoming = 'x'.repeat(2 ** 16);
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
length > 2 ** 16→length >= 2 ** 16Fixes #41142