node-http2 icon indicating copy to clipboard operation
node-http2 copied to clipboard

Server may crash when a request's socket is ended manually

Open JiaJiaJiang opened this issue 8 years ago • 4 comments

I use req.socket.end() to drop the requests that I won't response anything at all. This performances well with https module,but will crash with http2.

here is a crash log I got:

....../node_modules/http2/lib/protocol/connection.js:302
        var frame = stream.upstream.read((this._window > 0) ? this._window : -1);
                          ^

TypeError: Cannot read property 'upstream' of undefined
    at Connection._send (....../node_modules/http2/lib/protocol/connection.js:302:27)
    at processImmediate [as _immediateCallback] (timers.js:383:17)

JiaJiaJiang avatar Apr 22 '16 17:04 JiaJiaJiang

First off, yes, this is a bug. However - you shouldn't be manually closing down sockets with HTTP/2. If you wish to not respond to a request, you should instead send a RST_STREAM with error code REFUSED_STREAM. (Or, if you're feeling exceedingly mean to the peer, you can just ignore it - HTTP/2 is an inherently parallel protocol.) There is no reason to close down the socket unless something has gone horribly wrong on the connection (pretty much all of these are enumerated by 7540, and are handled internally by node-http2).

nwgh avatar Apr 22 '16 17:04 nwgh

Thank you for your suggestion. By the way,"you can just ignore it" means I can just not do anything on the request?Will these request objects keep in node?

JiaJiaJiang avatar Apr 22 '16 17:04 JiaJiaJiang

The request object will hang around, so just ignoring things isn't exactly suggested (unless you're ignoring them until a certain point in the future), but it won't break communication immediately (until you run out of memory).

nwgh avatar Apr 22 '16 19:04 nwgh

Thanks for your answer.I've understood how it works.Should I leave the issue here or close it?

JiaJiaJiang avatar Apr 23 '16 03:04 JiaJiaJiang