From 989ddfdf76f7f0cde0f1aa3893e1765b8d7af9b8 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. --- 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 d2701dfb84db12..64eef584fec06f 100644 --- a/lib/internal/http2/core.js +++ b/lib/internal/http2/core.js @@ -2151,14 +2151,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(); }