Skip to content

Commit 8fe62f8

Browse files
edeviltargos
authored andcommitted
http2: don't send trailers on a closed connection
There is a race condition between onStreamCloseResponse(), which removes the wantTrailers listener, and Http2Stream.close(), which will invalidate the connection. IE, sendTrailers can be called on a closed connection which would crash with a: Error [ERR_HTTP2_INVALID_STREAM]: The stream has been destroyed PR-URL: #23146 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Trivikram Kamat <[email protected]>
1 parent f98d441 commit 8fe62f8

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

‎lib/internal/http2/core.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,7 @@ function tryClose(fd){
330330
functiononStreamTrailers(){
331331
conststream=this[kOwner];
332332
stream[kState].trailersReady=true;
333-
if(stream.destroyed)
333+
if(stream.destroyed||stream.closed)
334334
return;
335335
if(!stream.emit('wantTrailers')){
336336
// There are no listeners, send empty trailing HEADERS frame and close.

0 commit comments

Comments
(0)