From 624fa4147ab26e93107f4d2db90c21840bc88807 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 11d677c5f66a31..95ce8bcdb4ede8 100644 --- a/lib/internal/http2/core.js +++ b/lib/internal/http2/core.js @@ -2152,14 +2152,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(); }