-
-
Notifications
You must be signed in to change notification settings - Fork 957
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
Starlette app hangs on Azure Functions when middleware based on BaseHTTPMiddleware is used #1320
Comments
After some hours debugging this, I've come to the conclusion that the issue is on Azure Functions. The problem lies on the fact that they are patching the If we add a simple /cc @tonybaloney Maybe you're interested in this? I was not able to debug the changes on the package while using the VSCode extension, otherwise I could have tried to push a fix for it there. 😞 |
Thanks so much for this investigation @Kludex. I've linked it on the Azure Functions repo too, so hopefully someone from Microsoft will pick it up. |
If someone is willing to teach me how to "live edit" the Azure Functions package while on the VSCode Azure plugin, I can try to submit a PR there. 😗 |
@Kludex you might have already found this, but here are the vscode tutorial https://docs.microsoft.com/en-us/azure/azure-functions/create-first-function-vs-code-python#run-the-function-locally 🤷 |
Looks like the easiest way to solve this is for |
Describe the bug
I am running a Starlette app through Azure Functions, using the ASGI support in Azure Functions to run the app. When I set up the app with no middlewares, it works fine. When I add the
CORSMiddleware
it also works fine, but when I add any middleware which is a subclass ofBaseHTTPMiddleware
, then all requests to the app hang and eventually timeout.To reproduce
A simple reproducible example is available here. This defines a simple Starlette app as follows:
This app is then deployed on Azure Functions, using their
AsgiMiddleware
class, which interfaces between Azure Functions triggers and ASGI requests. The code is all available in the repo, but the key part is__init__.py
, which contains:Expected behavior
App works with all types of middleware
Actual behavior
As you can see from the comments at the bottom of the app, this works with no middlewares, or just the
CORSMiddleware
, but hangs with theCustomHeaderMiddleware
which is derived fromBaseHTTPMiddleware
.Debugging material
As the app just hangs, there is no traceback to share.
Environment
Additional context
This was first discovered in a FastAPI app called titiler - see developmentseed/titiler#388. The author of that app realised it was only failing when using middleware which were a subclass of
BaseHTTPMiddleware
, and suggested I try with raw Starlette and post an issue here.The text was updated successfully, but these errors were encountered: