Skip to content

Commit 31bcaed

Browse files
committed
grpc-js: destroy connections when session begins
When the gRPC server has not been started, incoming connections can be destroyed on session establishment, which happens before a stream is created.
1 parent ffe59e6 commit 31bcaed

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

packages/grpc-js/src/server.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -284,11 +284,6 @@ export class Server {
284284
this.http2Server.on(
285285
'stream',
286286
(stream: http2.ServerHttp2Stream, headers: http2.IncomingHttpHeaders) => {
287-
if (!this.started) {
288-
stream.end();
289-
return;
290-
}
291-
292287
const contentType = headers[http2.constants.HTTP2_HEADER_CONTENT_TYPE];
293288

294289
if (
@@ -351,6 +346,13 @@ export class Server {
351346
}
352347
}
353348
);
349+
350+
this.http2Server.on('session', session => {
351+
if (!this.started) {
352+
session.destroy();
353+
return;
354+
}
355+
});
354356
}
355357
}
356358

0 commit comments

Comments
 (0)