Repository navigation
Commit 0de5452
committed
fix(eio): make the upgrade response an EventEmitter
WebSocketResponse exposes a subset of http.ServerResponse so that Express
middlewares can be applied to an upgrade request, but it was a plain
object. Any middleware that observes the response lifecycle — pino-http
and most other request loggers do, via res.on('close') — threw
"TypeError: res.on is not a function" and killed the upgrade.
Extend EventEmitter and emit "finish" then "close" once the handshake has
been written, so those middlewares run to completion instead of crashing.
statusCode is set to 101 so a logger reports the handshake rather than an
undefined status.1 parent 9738333 commit 0de5452
2 files changed
Lines changed: 44 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
685 | 685 | | |
686 | 686 | | |
687 | 687 | | |
688 | | - | |
| 688 | + | |
| 689 | + | |
| 690 | + | |
| 691 | + | |
| 692 | + | |
| 693 | + | |
689 | 694 | | |
690 | 695 | | |
691 | 696 | | |
692 | 697 | | |
| 698 | + | |
693 | 699 | | |
694 | 700 | | |
695 | 701 | | |
| |||
875 | 881 | | |
876 | 882 | | |
877 | 883 | | |
| 884 | + | |
| 885 | + | |
| 886 | + | |
| 887 | + | |
| 888 | + | |
878 | 889 | | |
879 | 890 | | |
880 | 891 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
249 | 249 | | |
250 | 250 | | |
251 | 251 | | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
252 | 284 | | |
253 | 285 | | |
254 | 286 | | |
| |||
0 commit comments