diff --git a/lib/internal/http2/core.js b/lib/internal/http2/core.js index 22ba4130717d36..11d677c5f66a31 100644 --- a/lib/internal/http2/core.js +++ b/lib/internal/http2/core.js @@ -2524,13 +2524,10 @@ class ServerHttp2Stream extends Http2Stream { this[kState].flags |= STREAM_FLAGS_HAS_TRAILERS; } - if (typeof fd !== 'number' && - !(fd instanceof fsPromisesInternal.FileHandle)) { - throw new ERR_INVALID_ARG_TYPE('fd', ['number', 'FileHandle'], fd); - } - - if (typeof fd !== 'number') // FileHandle + if (fd instanceof fsPromisesInternal.FileHandle) fd = fd.fd; + else if (typeof fd !== 'number') + throw new ERR_INVALID_ARG_TYPE('fd', ['number', 'FileHandle'], fd); debugStreamObj(this, 'initiating response from fd'); this[kUpdateTimer](); diff --git a/test/parallel/test-http2-respond-file-filehandle.js b/test/parallel/test-http2-respond-file-filehandle.js index df06b5d0fef7de..bc7bfbe356ff92 100644 --- a/test/parallel/test-http2-respond-file-filehandle.js +++ b/test/parallel/test-http2-respond-file-filehandle.js @@ -25,7 +25,7 @@ fs.promises.open(fname, 'r').then(common.mustCall((fileHandle) => { }); }); server.on('close', common.mustCall(() => fileHandle.close())); - server.listen(0, () => { + server.listen(0, common.mustCall(() => { const client = http2.connect(`http://localhost:${server.address().port}`); const req = client.request(); @@ -43,5 +43,5 @@ fs.promises.open(fname, 'r').then(common.mustCall((fileHandle) => { server.close(); })); req.end(); - }); + })); }));