Closed xmcp closed 3 months ago
I believe this is a bug, but not for the reasons stated above - sanic should not be accepting requests at all before the server starts, and therefore clients should get a connection refused on the listening port until the before_server_start
lifecycle event completes. Further, if it's running behind a proxy, this would necessitate the proxy returning a 502 because there was no open upstream connection during a sanic restart, which would allow a proxy that was doing health checks to mark the target as unhealthy and redirect to healthy targets (if there are any in the target group).
Closing this because unable to reproduce this on sanic 23.12. Not sure which commit fixed it though.
Describe the bug On Linux, dependency injection does not work for requests received during the
@app.before_server_start
code is executing, causing an HTTP 500 error.Screenshots Not related to swagger.
To Reproduce Run this code on a Linux machine:
It emulates a web application where the setup process (
@app.before_server_start
) takes 2s. During this time,test_client
requests the/test
endpoint with injected dependencies, which will result in HTTP 500.The console output looks like this:
Expected behavior
The above code works fine on Windows. Here is the console output on Windows:
Environment (please complete the following information):
Additional context I come across this bug when I restart a Sanic server behind an nginx. All queued requests when the backend is restarting get HTTP 500 responses.