-
-
Notifications
You must be signed in to change notification settings - Fork 189
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Kemal gets stuck for long response bodies #575
Comments
Crystal core interacted with HTTP::Server::Response by introducing Can we remove this code? I'm unclear on its use-cases. |
Kemal is having some issues in 0.35.0: kemalcr/kemal#575
same bug |
Same bug Crystal 0.35.1 Any response above 8kb is chunked & the connection is stuck. Tried specifying the |
Mints core testing is also broken due to this bug, the browser awaits a WS response from the server that never arrives, timed out. |
FYI, until #576 is merged, in order to apply that patch locally you can include the following in your project somewhere after class HTTP::Server::Response
class Output
# original definition since Crystal 0.35.0
def close
return if closed?
unless response.wrote_headers?
response.content_length = @out_count
end
ensure_headers_written
super
if @chunked
@io << "0\r\n\r\n"
@io.flush
end
end
# patch from https://github.com/kemalcr/kemal/pull/576
def close
# ameba:disable Style/NegatedConditionsInUnless
unless response.wrote_headers? && !response.headers.has_key?("Content-Range")
response.content_length = @out_count
end
ensure_headers_written
previous_def
end
end
end Eventually if/when crystal std-lib http improves its support for Content-Range the monkey-patch in kemal itself will be able to go away. |
After ubuntu updated my crystal to 0.35 unexpectedly (lol), My kemal app suddenly started having this behavior where chrome would show the "page loading" spinner indefinitely. And it was difficult to see responses in the devtools. They would visibly show up in the normal browser, but no data would show up in chrometools. It seems as kemal did not close the request correctly, causing chrome to anticipate more data even though it was complete. This new behavior was fixed by this snippet (posted above) #575 (comment) |
Full URL of the issue: kemalcr/kemal#575
Full URL of the issue: kemalcr/kemal#575
Description
After upgrading to Crystal 0.35.0 on Kemal's master branch I'm having issues with responding with long strings.
Steps to Reproduce
get "/" { "my_string," * 1_000 }
curl localhost:3000
Expected behavior: I expect the app to return a long self-repeating string with a connection properly closed.
Actual behavior: My curl get stuck forever printing only the first chunk. Obviously, it works as buggy in browser.
Reproduces how often: Seems to happen for a string that needs to be chunked as per Transfer-Encoding requirements.
Versions
Crystal 0.35.0 (2020-06-09)
LLVM: 10.0.0
Default target: x86_64-apple-macosx
Persists for both OSs: macOS Catalina 10.15.4 and Ubuntu 18.04
The text was updated successfully, but these errors were encountered: