-
-
Notifications
You must be signed in to change notification settings - Fork 128
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
Problems with Sanic 23.3.0 and Mangum 0.17.0 #300
Comments
@ahopkins here is the issue I was talking about :) |
My initial reaction is that it sounds like maybe |
Just curious, what asgi server are you running this with? |
Mangum basically acts like a translator between an aws lambda request structure and what an asgi server would send to Sanic or FastAPI or any of the others. |
I ran into the same problem yesterday and below is my quick hack to make it work. This has only been tested locally with SAM. The problem is that Sanic expects that scope has raw path in This issue is from July 25, it should have been fixed by now. Am I missing something? class MangumWrapper(mangum.Mangum):
def __init__(self, app: Sanic[Config, SimpleNamespace]) -> None:
super().__init__(app)
def __call__(self, event: LambdaEvent, context: LambdaContext) -> dict:
handler = self.infer(event, context)
crafted_scope = {**handler.scope, "raw_path": handler.scope["path"].encode()}
with ExitStack() as stack:
if self.lifespan in ("auto", "on"):
lifespan_cycle = LifespanCycle(self.app, self.lifespan)
stack.enter_context(lifespan_cycle)
http_cycle = HTTPCycle(crafted_scope, handler.body)
http_response = http_cycle(self.app)
return handler(http_response) |
This doesn't seem correct... You aren't supposed to get the Also, by the ASGI specification, it's possibl for the |
On a cold start I get this:
And this on a warm call:
I don't know what versions of which are compatible with each other but the latest of each is not. I used the example from https://mangum.io/asgi-frameworks/#sanic. I had to add a name to the
Sanic()
instance because they require that now but I can not figure out what else might now be required to work with Mangum or if Mangum needs interal adjustments to work with Sanic.Here is my full example of what I am using:
The text was updated successfully, but these errors were encountered: