Skip to content

Commit 368e058

Browse files
committed
chore: cleanups from code review
Allow WSServerDelegate.onConnection to return undefined instead of a no-op connection, align the upgrade 403 status line in HttpServer with WSServer.
1 parent f0aaa97 commit 368e058

3 files changed

Lines changed: 3 additions & 3 deletions

File tree

packages/playwright-core/src/tools/mcp/cdpRelay.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ export class CDPRelayServer {
102102
this._handlePlaywrightConnection(ws);
103103
else
104104
this._handleExtensionConnection(ws);
105-
return { close: async () => {} };
105+
return undefined;
106106
},
107107
});
108108
}

packages/utils/httpServer.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ export class HttpServer {
9090
if (pathname !== wsPath)
9191
return;
9292
if (!isAllowedHost(request, this._allowedHosts)) {
93-
socket.write('HTTP/1.1 403 Forbidden\r\n\r\n');
93+
socket.write(`HTTP/${request.httpVersion} 403 Forbidden\r\n\r\n`);
9494
socket.destroy();
9595
return;
9696
}

packages/utils/wsServer.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ export type WSServerDelegate = {
4646
onRequest: (request: http.IncomingMessage, response: http.ServerResponse) => void;
4747
onHeaders: (headers: string[]) => void;
4848
onUpgrade: (request: http.IncomingMessage, socket: stream.Duplex) => { error: string } | undefined;
49-
onConnection: (request: http.IncomingMessage, url: URL, ws: WebSocket, id: string) => WSConnection;
49+
onConnection: (request: http.IncomingMessage, url: URL, ws: WebSocket, id: string) => WSConnection | undefined;
5050
isAllowedPathname: (pathname: string) => boolean;
5151
};
5252

0 commit comments

Comments
 (0)