Closed aersam closed 3 months ago
This looks like #216. Even after the long discussions and debugging, it's still unclear to me why Starlette fails in using its own response stream code (that assertion checks a ASGI message sent by starlette, not Granian).
I don't have any quick solution for this, I might spend some time trying to debug Starlette internals with Granian in the following weeks, but I'm not sure it will lead to any result.
Just a quick thing: any specific reason you're explicitly avoiding uvloop
on a Unix OS? My gut tells me this is some concurrency issue with Starlette, uvloop might just automagically solve it.
The --loop was just an attempt to fix it, it's the same behavior. FYI: My Production Environment uses Linux and Python 3.12, it's an azure website
@aersam can you please provide a MRE including (but not limited to) the list of middlewares you're using?
The MRE is hard since I could not reproduce this, not on Windows nor on WSL. But I monkey-patched Starlette and have a better error message now :)
AssertionError: Unexpected message of type http.response.pathsend from class <class 'starlette.middleware.base.BaseHTTPMiddleware'>: {'type': 'http.response.pathsend', 'path': 'frontend_app/output/index.html'}
The MRE is hard since I could not reproduce this, not on Windows nor on WSL. But I monkey-patched Starlette and have a better error message now :)
AssertionError: Unexpected message of type http.response.pathsend from class <class 'starlette.middleware.base.BaseHTTPMiddleware'>: {'type': 'http.response.pathsend', 'path': 'frontend_app/output/index.html'}
Oh, that's actually a Starlette bug then! Can you please open an issue in the Starlette repo mentioning this as the starting point?
cc @Kludex
I'm closing this since we now have https://github.com/encode/starlette/issues/2613 and https://github.com/encode/starlette/pull/2616
Hi there
I've been trying to use startlette on some app of mine, and it worked well locally. In production however I get this strange error:
My startup command is
granian application:app --host 0.0.0.0 --port 8000 --workers 2 --interface asgi --loop asyncio
The route producing the error is very simple (starlette/fastapi)
Any idea what could cause such an error?