Guard finally-block logger.info in HTTP access log middleware (#67501)
The ``finally`` block in ``HttpAccessLogMiddleware`` called ``logger.info()`` without exception protection. If ``logger.info()`` raised — broken handler, OOM in the formatter, downstream forwarder unavailable — and the original ``try`` block was already propagating an application exception, Python's ``finally``-replacement semantics would discard the original exception in favour of the logger's, so uvicorn never saw the real failure. Wrap the emit in ``contextlib.suppress(Exception)`` so logging failures never disrupt the application or mask the original exception. The HTTP response has already been sent to the client by the time we reach the log emit, so swallowing the logger failure costs nothing beyond a missing log line for that one request.
J
Jarek Potiuk committed
b66f4433e004fad81b66023bd8caccee55e6e4f7
Parent: fd9241c
Committed by GitHub <noreply@github.com>
on 5/28/2026, 6:55:01 AM