You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Jul 6, 2018. It is now read-only.
I'm using Http2Stream.respondWithFile from an app that also uses the compatibility layer. Error handling is getting pretty bloated, IMO, because the stream error event is broadcasted to both request and response.
Current code:
constnoop=()=>{}request.on('error',noop)response.on('error',noop)response.stream.on('error',()=>{request.removeListener('error',noop)response.removeListener('error',noop)if(response.stream.destroyed===false){response.writeHead(500,{'content-type': 'text/plain'})response.end('Internal Server Error')}})response.stream.respondWithFile('/my/file/path',response.getHeaders())
Desired code:
response.stream.on('error',()=>{if(response.stream.destroyed===false){response.writeHead(500,{'content-type': 'text/plain'})response.end('Internal Server Error')}})response.stream.respondWithFile('/my/file/path',response.getHeaders())
What would be needed is to rename or stop propagating stream error events. It's a very simple change in the two error event handlers (for res and req). However I'm hesitant because I don't know what the thought process was behind that broadcasting.
Perhaps related, socket:error events do not seem to bubble up to the req/res instances in the http1 layer.