Skip to content

Commit 653869e

Browse files
committed
fix(reactive-rpc): 🐛 route WebSocket traffic correctly
1 parent d7555e3 commit 653869e

File tree

2 files changed

+4
-5
lines changed

2 files changed

+4
-5
lines changed

src/reactive-rpc/server/http1/Http1Server.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ export interface WsEndpointDefinition {
4646
maxIncomingMessage?: number;
4747
maxOutgoingBackpressure?: number;
4848
onUpgrade?(req: http.IncomingMessage, connection: WsServerConnection): void;
49-
onConnect(ctx: WsConnectionContext, req: http.IncomingMessage): void;
49+
handler(ctx: WsConnectionContext, req: http.IncomingMessage): void;
5050
}
5151

5252
export interface Http1ServerOpts {
@@ -174,8 +174,7 @@ export class Http1Server implements Printable {
174174
path = url.slice(0, queryStartIndex);
175175
query = url.slice(queryStartIndex + 1);
176176
}
177-
const route = (req.method || '') + path;
178-
const match = this.wsMatcher(route);
177+
const match = this.wsMatcher(path);
179178
if (!match) {
180179
socket.end();
181180
return;
@@ -213,7 +212,7 @@ export class Http1Server implements Printable {
213212
const secWebSocketProtocol = headers['sec-websocket-protocol'] ?? '';
214213
if (typeof secWebSocketProtocol === 'string') setCodecs(ctx, secWebSocketProtocol, codecs);
215214
}
216-
def.onConnect(ctx, req);
215+
def.handler(ctx, req);
217216
};
218217

219218
public ws(def: WsEndpointDefinition): void {

src/reactive-rpc/server/http1/RpcServer.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ export class RpcServer implements Printable {
132132
path,
133133
maxIncomingMessage: 2 * 1024 * 1024,
134134
maxOutgoingBackpressure: 2 * 1024 * 1024,
135-
onConnect: (ctx: WsConnectionContext, req: http.IncomingMessage) => {
135+
handler: (ctx: WsConnectionContext, req: http.IncomingMessage) => {
136136
const connection = ctx.connection;
137137
const reqCodec = ctx.reqCodec;
138138
const resCodec = ctx.resCodec;

0 commit comments

Comments
 (0)