Skip to content

Commit

Permalink
http2: fix file close error condition at respondWithFd
Browse files Browse the repository at this point in the history
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 <[email protected]>
Reviewed-By: Ruben Bridgewater <[email protected]>
Reviewed-By: Anto Aravinth <[email protected]>
Reviewed-By: David Carlier <[email protected]>
Reviewed-By: Yongsheng Zhang <[email protected]>
Reviewed-By: Luigi Pinca <[email protected]>
Reviewed-By: Minwoo Jung <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Gus Caplan <[email protected]>
  • Loading branch information
addaleax authored and targos committed Nov 8, 2019
1 parent 808a302 commit b185a52
Showing 1 changed file with 1 addition and 4 deletions.
5 changes: 1 addition & 4 deletions lib/internal/http2/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -2174,14 +2174,11 @@ function processHeaders(oldHeaders) {
return headers;
}

function onFileCloseError(stream, err) {
stream.emit(err);
}

function onFileUnpipe() {
const stream = this.sink[kOwner];
if (stream.ownsFd)
this.source.close().catch(onFileCloseError.bind(stream));
this.source.close().catch(stream.destroy.bind(stream));
else
this.source.releaseFD();
}
Expand Down

0 comments on commit b185a52

Please sign in to comment.