From ac1f56118aca06e8753134b7f5400e16c2cb00c3 Mon Sep 17 00:00:00 2001 From: Adam Hopkins Date: Mon, 20 Mar 2023 13:00:34 +0200 Subject: [PATCH] Skip middleware on RequestCancelled (#2720) --- sanic/http/http1.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/sanic/http/http1.py b/sanic/http/http1.py index 304e5e5e..5884d0b4 100644 --- a/sanic/http/http1.py +++ b/sanic/http/http1.py @@ -428,7 +428,9 @@ class Http(Stream, metaclass=TouchUpMeta): if self.request is None: self.create_empty_request() - request_middleware = not isinstance(exception, ServiceUnavailable) + request_middleware = not isinstance( + exception, (ServiceUnavailable, RequestCancelled) + ) try: await app.handle_exception( self.request, exception, request_middleware