Commit a434502
authored
fix: native WebSocket over H2 server after undici import (#4990)
* fix: native WebSocket over H2 server after undici import (#4989)
Importing undici v8 overwrites the legacy global dispatcher
(Symbol.for('undici.globalDispatcher.1')) used by Node.js's bundled
undici. The new Agent defaults to allowH2: true, causing ALPN to
negotiate h2. Undici v8's fetch has a fallback
(dispatchWithProtocolPreference) that retries with HTTP/1.1 when
Extended CONNECT is unavailable, but the bundled undici does not.
Fix Dispatcher1Wrapper.dispatch() to force allowH2: false for upgrade
requests, since legacy consumers cannot handle the H2 WebSocket
fallback.
Fixes: #4989
Signed-off-by: Matteo Collina <hello@matteocollina.com>
* fix: disable HTTP/2 for legacy (v1) dispatcher consumers
Legacy (v1) consumers (like Node.js's bundled undici on Node 22)
do not support HTTP/2. Force allowH2: false in Dispatcher1Wrapper
so that the v1 global dispatcher always uses HTTP/1.1.
Also add NODE_TLS_REJECT_UNAUTHORIZED for the regression test
since native WebSocket uses the bundled dispatcher without
rejectUnauthorized override.
Signed-off-by: Matteo Collina <hello@matteocollina.com>
---------
Signed-off-by: Matteo Collina <hello@matteocollina.com>1 parent d3ea390 commit a434502
2 files changed
Lines changed: 86 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
86 | 86 | | |
87 | 87 | | |
88 | 88 | | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
89 | 95 | | |
90 | 96 | | |
91 | 97 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
0 commit comments