From 5959023b7661985254023d4e793806aa9416824e Mon Sep 17 00:00:00 2001 From: Anna Henningsen Date: Tue, 8 Oct 2019 15:26:44 +0200 Subject: [PATCH] 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: https://github.com/nodejs/node/pull/29884 Reviewed-By: Colin Ihrig Reviewed-By: Ruben Bridgewater Reviewed-By: Anto Aravinth Reviewed-By: David Carlier Reviewed-By: Yongsheng Zhang Reviewed-By: Luigi Pinca Reviewed-By: Minwoo Jung Reviewed-By: James M Snell Reviewed-By: Gus Caplan --- lib/internal/http2/core.js | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/lib/internal/http2/core.js b/lib/internal/http2/core.js index 28c91ee22d8f6d..f4e419b0f88334 100644 --- a/lib/internal/http2/core.js +++ b/lib/internal/http2/core.js @@ -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(); }