1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-12-24 08:09:08 -05:00

fix(node): update req.socket on WS upgrade (#21984)

Update the `req.socket` to be a `net.Socket` from `FakeSocket`

Fixes #21979
This commit is contained in:
Divy Srivastava 2024-01-18 22:24:02 +05:30 committed by GitHub
parent 2141543105
commit 66ff28c21e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 5 additions and 1 deletions

View file

@ -716,7 +716,9 @@ Deno.test(
});
// @ts-ignore it's a socket for real
let serverSocket;
server.on("upgrade", (_req, socket, _head) => {
server.on("upgrade", (req, socket, _head) => {
// https://github.com/denoland/deno/issues/21979
assert(req.socket?.write);
socket.write(
"HTTP/1.1 101 Web Socket Protocol Handshake\r\n" +
"Upgrade: WebSocket\r\n" +

View file

@ -1637,6 +1637,8 @@ export class ServerImpl extends EventEmitter {
const socket = new Socket({
handle: new TCP(constants.SERVER, conn),
});
// Update socket held by `req`.
req.socket = socket;
this.emit("upgrade", req, socket, Buffer.from([]));
return response;
} else {