-
-
Notifications
You must be signed in to change notification settings - Fork 32
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
[Bug] Sanic serving request before injection complete #203
Comments
After posting this, I realize that it is probably due to my init function being asynchronous. So any suggestion how to deal with that? @dataclass
class Realm:
@classmethod
async def from_header(cls, request: Request):
# do something here
return cls()
app.ext.add_dependency(Realm, Realm.from_header) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Describe the bug
I did set
app.config.INJECTION_SIGNAL = "http.handler.before"
, but when the server start, there is a split second where the handler runs before the injection finish, and it will throw an error with missing param.In a normal situation, this wouldn't be an issue, but when using auto scaling (like Google Cloud Run), the instance is spun up to serve the request, then the first request will always result in a 500 error.
Expected behavior
The handler will be called after the injection finish
Environment (please complete the following information):
sanic==23.3.0
sanic-ext==23.3.0
The text was updated successfully, but these errors were encountered: