fix: Fix lifespan app handler not working

It was noticed that shutdown handlers for implementations are not
executed.

Investigation reveals that lifespan logic is not working. When server
starts, we see:

```
ASGI 'lifespan' protocol appears unsupported.
```

This is because uvicorn calls to app with a missing path on startup,
(perhaps to detect that the protocol is working?) and our
TracingMiddleware was not ready for that, resulting in an exception and
lifespan logic disabled.

Fixes #188

Signed-off-by: Ihar Hrachyshka <ihar.hrachyshka@gmail.com>
This commit is contained in:
Ihar Hrachyshka 2025-03-10 19:59:10 +00:00
parent e4acdf6d54
commit 056eb68fcc

View file

@ -215,7 +215,7 @@ class TracingMiddleware:
self.app = app
async def __call__(self, scope, receive, send):
path = scope["path"]
path = scope.get("path", "")
await start_trace(path, {"__location__": "server"})
try:
return await self.app(scope, receive, send)