Skip to content

Commit 624fa41

Browse files
addaleaxTrott
authored andcommitted
http2: fix file close error condition at respondWithFd
Closing a FileHandle almost never fails, so it was hard to notice before that `stream.emit(err)` would not emit an error event due to the missing event name. Destroying the stream with the error seems like the right thing to do in that scenario. PR-URL: #29884 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Anto Aravinth <anto.aravinth.cse@gmail.com> Reviewed-By: David Carlier <devnexen@gmail.com> Reviewed-By: Yongsheng Zhang <zyszys98@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Minwoo Jung <minwoo@nodesource.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Gus Caplan <me@gus.host>
1 parent 5133e78 commit 624fa41

File tree

1 file changed

+1
-4
lines changed

1 file changed

+1
-4
lines changed

lib/internal/http2/core.js

+1-4
Original file line numberDiff line numberDiff line change
@@ -2152,14 +2152,11 @@ function processHeaders(oldHeaders) {
21522152
return headers;
21532153
}
21542154

2155-
function onFileCloseError(stream, err) {
2156-
stream.emit(err);
2157-
}
21582155

21592156
function onFileUnpipe() {
21602157
const stream = this.sink[kOwner];
21612158
if (stream.ownsFd)
2162-
this.source.close().catch(onFileCloseError.bind(stream));
2159+
this.source.close().catch(stream.destroy.bind(stream));
21632160
else
21642161
this.source.releaseFD();
21652162
}

0 commit comments

Comments
 (0)