-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
The Sanic built-in server blocks for exactly 90 seconds on status code 412 #2823
Comments
Thanks for the report. This affects HTTP status The response gets sent immediately (use Triaging: Notes: return sanic.text("4\r\nBUGS\r\n0\r\n\r\n", status=412, headers={"transfer-encoding": "chunked"}) I believe the 412 handling of Sanic as it is now is broken and handled in wrong location, causing this confusion within HTTP protocol (at least HTTP1, didn't check HTTP3 or ASGI). For those status codes in addition to entity headers also Referring to @ahopkins for further review. |
Status code 304 is NOT affected because it is correctly handled by Checking the HTTP RFC, I cannot find why entity headers or body should be stripped off 412 responses. Removing that stripping would allow body in such responses, which seems correct. |
Thanks for finding the issue and responding so quickly — makes sense. I wonder why specifically 412 was treated differently. :)
Makes sense then, so the 90 seconds is a TCP timeout. |
* Add test for issue #2823 * Do not strip entity-headers. * Remove unused import * Remove remove_entity_headers() * Add workflow_dispatch release * RTD build fix * RTD build fix (another) * RTD build fix (yet another) * Update Crowdin configuration file * Fix Docker publish (#2887) * Fix Docker publish * Remove workflow dispatch The actions uses data from the release object itself, so workflow dispatch doesn't work anyway * More fixes * Remove test for removed functionality. --------- Co-authored-by: L. Kärkkäinen <[email protected]> Co-authored-by: Adam Hopkins <[email protected]> Co-authored-by: Néstor Pérez <[email protected]>
Is there an existing issue for this?
Describe the bug
Sanic, like most web servers, usually responds to requests. However, if the response has status code 412, it is very slow and takes exactly 90 extra seconds to respond, stalling after the handler finishes.
This behavior does not happen when running Sanic with uvicorn. Only the official Sanic server. It also doesn't happen with FastAPI.
Code snippet
Expected Behavior
Then:
How do you run Sanic?
Sanic CLI
Operating System
Linux
Sanic Version
Sanic v23.6.0
Additional context
I have reproduced this on both Linux and macOS. I have also reproduced this using both the Sanic CLI and the
Sanic.serve()
function programmatically.The text was updated successfully, but these errors were encountered: