oesmith / puffing-billy

A rewriting web proxy for testing interactions between your browser and external sites. Works with ruby + rspec.
MIT License
659 stars 170 forks source link

Rescue Errno::ECONNRESET in shutdown phase #307

Closed urbanautomaton closed 3 years ago

urbanautomaton commented 3 years ago

While waiting for shutdown, the proxy attempts to connect to the event machine TCP socket in a loop until the connection fails to be made.

There's a small possibility here that the connection is established but the socket is closed by the remote before the poller closes it, in which case we get an Errno::ECONNRESET exception that isn't currently handled.

I think this error also indicates that we've shut down successfully, so this PR adds it to the existing rescue.

Feedback

I think it's safe to conclude that EM has shut down as a result of this error, but there might be other explanations for the reset; would we prefer to go round the loop again in this case and wait for one of the other errors?

Also, I didn't see an obvious place to add a test for this behaviour, and concluded that since it's a small addition to an existing rescue, that was fine. Does that sound reasonable?

ronwsmith commented 3 years ago

Agreed on all points. Will get this in soon. Thanks for the contribution!

ronwsmith commented 3 years ago

Released in 2.4.1