Skip to content

Comments

fix: route WebSocket upgrades through onRequestUpgrade#4787

Merged
mcollina merged 1 commit intomainfrom
fix-websocket-onrequestupgrade
Feb 9, 2026
Merged

fix: route WebSocket upgrades through onRequestUpgrade#4787
mcollina merged 1 commit intomainfrom
fix-websocket-onrequestupgrade

Conversation

@mcollina
Copy link
Member

@mcollina mcollina commented Jan 31, 2026

Summary

  • deliver WebSocket upgrade responses through the documented onRequestUpgrade handler
  • keep legacy onUpgrade handling for compatibility

Fixes #4771.

Testing

  • npm test (fails in test:wpt: many existing XHR failures; other suites passed)

@codecov-commenter
Copy link

Codecov Report

❌ Patch coverage is 8.57143% with 32 lines in your changes missing coverage. Please review.
✅ Project coverage is 93.16%. Comparing base (352c691) to head (f44a6bc).

Files with missing lines Patch % Lines
lib/web/fetch/index.js 8.57% 32 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4787      +/-   ##
==========================================
- Coverage   93.25%   93.16%   -0.09%     
==========================================
  Files         109      109              
  Lines       34024    34059      +35     
==========================================
+ Hits        31729    31732       +3     
- Misses       2295     2327      +32     

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

Copy link
Member

@KhafraDev KhafraDev left a comment

Choose a reason for hiding this comment

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

I don't think there's any harm, but isn't this running twice since onUpgrade forwards to onRequestUpgrade?

@metcoder95
Copy link
Member

It depends on the handler shape I believe; the wrapper/unwrapper usually does this translation

@mcollina
Copy link
Member Author

mcollina commented Feb 9, 2026

@KhafraDev what @metcoder95 said. It's more about supporting interceptors correctly.

@mcollina mcollina merged commit 2453caf into main Feb 9, 2026
36 of 37 checks passed
@mcollina mcollina deleted the fix-websocket-onrequestupgrade branch February 9, 2026 11:06
@github-actions github-actions bot mentioned this pull request Feb 13, 2026
slagiewka pushed a commit to slagiewka/undici that referenced this pull request Feb 14, 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.

Undici WebSocket only uses undocumented onUpgrade() handler, not documented onRequestUpgrade().

4 participants