-
Notifications
You must be signed in to change notification settings - Fork 87
reel 0.5.0: Reel::StateError: already processing a request when client is killed #150
Comments
This is due to the introduction of pipelining, which requires that you completely consume the request before trying to process the next. Perhaps Reel should do this implicitly, or let you turn pipelining off. Until then, you need to consume the entire request body. |
Is there a way to make sure that the entire request body is consumed? Does this also work if a curl client is killed or a browser rendering a web application that uses a reel server as back-end refreshes at the "wrong" moment? |
You can call |
As far as I understand calling to_str on the body does not help as the server crashes before accessing the body. (Line 14 in the following gist: https://gist.github.com/rakvat/b0ff391fdd531873c8f6) |
The first request doesn't go through? My guess is you're trying to read the next request before the first request's body has been consumed. |
I'm seeing similar behavior. I tried out your barebones hello world example and hit it with apache bench to try out some concurrency. It crashed:
I tried adding |
I debugged the issue with reel-0.5.0 and option spy: true. (The setup is still parallel curl requests, pkill -f curl, reel crashes.) There are many requests going through before I kill curl. The normal flow in lib/reel/connection.rb is 1) client connects, 2) initialize sets current_request to nil, 3) each_request calls request which sets current_request to a request object, 4) connection#respond gets called which calls current_request.handle_response and then resets current_request to nil. When I kill curl (simulating a browser refresh) the flow in connection.rb is 1), 2), 3) as above, 4) current_request.handle_response raises a Broken Pipe Exception. Thus current_request is not reset to nil. The next time each_request calls request a StateError is raised as current_request is not nil. I hope this helps. |
I have a minimal reel server copied from the "Subclass Form" reel example that does some work before sending the response.
When I run it with reel 0.5.0. and http 0.6.1, send curl requests to the server and do 'pkill -f curl' while requests are running, the reel server crashes with 'Reel::StateError: already processing a request'.
The same setup with reel 0.4.0 and http 0.5.0 does not crash.
The text was updated successfully, but these errors were encountered: