spdy-http2/node-spdy

Got "Can't send request after GOAWAY" error

richardkazuomiller opened this issue · 2 comments

I'm making requests using spdy@3.4.2 to make requests to an HTTP2 server (Google Cloud Load Balancing) and the error Can't send request after GOAWAY was thrown and the process crashed.

How can I handle this so the client can make a new connection when the server wants it to "go away"? Is there some kind of GOAWAY event fired so I can create a new agent or something?

I did some digging and found that spdyAgent._spdyState.connection._spdyState.goaway is a thing. If that's truthy !== false, I create a new agent before making a request, and that seems to make things better. Does that make sense? I'm not super familiar with the details of the h2 spec.

I think reconnection should either be done automatically by the agent or there should be a more obvious way to figure out if an agent needs to reconnect.

Update in case anyone reads this and uses my solution:

_spdyState.goaway can sometimes be 0 if GOAWAY is the first thing it receives so checking if goaway is truthy is not good enough – it must be not false.