Skip to content

fix(websocket/stream): only enqueue parsed messages in WebSocketStream#4959

Merged
tsctx merged 1 commit intonodejs:mainfrom
colinaaa:main
Apr 3, 2026
Merged

fix(websocket/stream): only enqueue parsed messages in WebSocketStream#4959
tsctx merged 1 commit intonodejs:mainfrom
colinaaa:main

Conversation

@colinaaa
Copy link
Copy Markdown
Contributor

@colinaaa colinaaa commented Apr 2, 2026

This relates to...

Fixes #4958

Rationale

WebSocketStream#opened.readable should only expose parsed WebSocket message payloads.
Before this change, the stream could also enqueue raw socket bytes, which intermittently produced malformed text data (for example leading ) and broke JSON parsing for text frames.

Changes

Bug Fixes

  • Remove raw-socket enqueue path from WebSocketStream readable stream setup.
  • Keep readable output sourced from parser message callbacks only.
  • Add regression test test/websocket/stream/issue-4958.js to reproduce and guard against the issue.

Breaking Changes and Deprecations

None.

Status

@mcollina mcollina requested a review from KhafraDev April 2, 2026 09:52
Copy link
Copy Markdown
Member

@mcollina mcollina left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@codecov-commenter
Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 92.93%. Comparing base (d7fbba5) to head (11afb73).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #4959   +/-   ##
=======================================
  Coverage   92.92%   92.93%           
=======================================
  Files         111      111           
  Lines       35831    35825    -6     
=======================================
- Hits        33297    33293    -4     
+ Misses       2534     2532    -2     

☔ 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.

@tsctx tsctx merged commit 49ded6d into nodejs:main Apr 3, 2026
33 of 34 checks passed
@github-actions github-actions Bot mentioned this pull request Apr 3, 2026
mcollina pushed a commit that referenced this pull request Apr 29, 2026
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.

WebSocketStream sometimes mixes non-message bytes into opened.readable

5 participants