Closed
Description
I'm using the http2.createSecureServer with a request handler which passes request (as req
) and response (as res
) streams to the handler.
I am using res.stream.respondWithFile()
I am trying to catch errors where the file is not found, so I listen for error event on the stream so my code is like below
res.stream.on('error', err => {
if (forwardError || !(err.code === 'ENOENT')) {
next(err);
} else {
//this was probably file not found, in which case we just go to next middleware function.
next();
}
});
res.stream.respondWithFile(
filename,
{ 'content-type': map[ext] || 'text/plain',
'cache-control': 'no-cache' },
{ statCheck });
Even though I am handling the stream error, I am getting the same error reflected again on both req
and res
variables.
This is fundamentally the following issue with a slight twist (listening to the stream error)
nodejs/http2#168
which was raised before the code landed in node and is is still open