Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 34.4k
Description
- Version: v10.2.1
- Platform: Linux 4.9.0-6-amd64 SMP Debian 4.9.88-1 x86_64 GNU/Linux
- Subsystem: http2
Sorry for my english.
From time to time session emit error that is not handle by server/listener "error", "streamError" or "sessionError" handlers:
events.js:167 throw er; // Unhandled 'error' event ^ Error [ERR_HTTP2_SESSION_ERROR]: Session closed with error code 1 at Http2Session.onGoawayData (internal/http2/core.js:477:21) at SocketProxy.ondata (internal/wrap_js_stream.js:62:22) at SocketProxy.emit (events.js:182:13) at addChunk (_stream_readable.js:279:12) at readableAddChunk (_stream_readable.js:264:11) at SocketProxy.Readable.push (_stream_readable.js:219:10) at SocketProxy._read (/xxx/node_modules/@webcarrot/server/lib/SocketProxy.js:81:21) at SocketProxy.tryRead (/xxx/node_modules/@webcarrot/server/lib/SocketProxy.js:99:12) at SocketProxy.addChunk (/xxx/node_modules/@webcarrot/server/lib/SocketProxy.js:92:10) at Socket.handleData (/xxx/node_modules/@webcarrot/server/lib/SocketProxy.js:26:61) at Socket.emit (events.js:182:13) at addChunk (_stream_readable.js:279:12) at readableAddChunk (_stream_readable.js:264:11) at Socket.Readable.push (_stream_readable.js:219:10) at Pipe.onread (net.js:636:20) Emitted 'error' event at: at emitErrorNT (internal/streams/destroy.js:82:8) at emitErrorAndCloseNT (internal/streams/destroy.js:50:3) at process._tickCallback (internal/process/next_tick.js:63:19)Looks like session emit unhandled error on destroy.
This error should be handle by server sessionError to prevent app crash/restart.
More info:
@webcarrot/server/lib/SocketProxy (same name in wrap_js_stream 👎 ) is duplex stream that wrap connection stream ( #17132 ):
https://gist.github.com/webcarrot/353c2f275ab234f5dc68f9c7b32d40ea
Server class looks like (extends plain Http2Server):
https://gist.github.com/webcarrot/e61e78e4562bf843248bacedfe3663e8
PROXY protocol server wrapper (extends extended server class):
https://gist.github.com/webcarrot/9a6c0a3d4bc6f4665465ac57dd3be373
Simple usage (not real but probably work via haproxy or similar):
importproxyWrapfrom"./proxyWrap";import{Server}from"./PlainHttp2";const{createServer}=proxyWrap({ Server });consth2Listener=createServer({allowHTTP1: true},(req,res)=>{// some handlerres.end("test");});h2Listener.addListener("error",err=>console.error("server error",err));h2Listener.addListener("streamError",err=>console.error("stream error",err));h2Listener.addListener("sessionError",err=>console.error("session error",err));h2Listener.listen("/unix/socket/etc",err=>err&&console.error("listen error",err));