Skip to content

fix(websocket): use 1002 close code on parser errors#5051

Open
deepview-autofix wants to merge 1 commit intonodejs:mainfrom
deepview-autofix:deepview/16a8cbebeb
Open

fix(websocket): use 1002 close code on parser errors#5051
deepview-autofix wants to merge 1 commit intonodejs:mainfrom
deepview-autofix:deepview/16a8cbebeb

Conversation

@deepview-autofix
Copy link
Copy Markdown
Contributor

onParserError passed null as the close code to failWebsocketConnection, causing closeWebSocketConnection to default the code to 1000 ("Normal Closure") whenever the reason string was non-empty. Protocol errors (invalid frames, RSV bit violations, etc.) surfaced through the parser were thus reported to the peer as normal closures instead of 1002 ("Protocol Error"), violating RFC 6455 section 7.4.1.

onParserError passed null as the close code to failWebsocketConnection,
causing closeWebSocketConnection to default the code to 1000 ("Normal
Closure") whenever the reason string was non-empty. Protocol errors
(invalid frames, RSV bit violations, etc.) surfaced through the parser
were thus reported to the peer as normal closures instead of 1002
("Protocol Error"), violating RFC 6455 section 7.4.1.

Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: DeepView Autofix <276251120+deepview-autofix@users.noreply.github.com>
Co-Authored-By: Nikita Skovoroda <chalkerx@gmail.com>
Signed-off-by: Nikita Skovoroda <chalkerx@gmail.com>
@codecov-commenter
Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.03%. Comparing base (d2e8178) to head (664aebe).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #5051   +/-   ##
=======================================
  Coverage   93.03%   93.03%           
=======================================
  Files         110      110           
  Lines       35793    35793           
=======================================
+ Hits        33299    33300    +1     
+ Misses       2494     2493    -1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@KhafraDev
Copy link
Copy Markdown
Member

Instead of a simulated error, could we test for one of the following?

Protocol errors (invalid frames, RSV bit violations, etc.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants