From f3f799deef5e4258a647b598614779ec5b29bccc Mon Sep 17 00:00:00 2001 From: Erik Johnston Date: Wed, 27 Mar 2024 16:53:44 +0000 Subject: [PATCH 1/2] Fix twisted mypy --- synapse/http/proxy.py | 3 ++- synapse/http/server.py | 4 ++-- synapse/http/site.py | 3 ++- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/synapse/http/proxy.py b/synapse/http/proxy.py index 6cbbd5741b..5b5ded757b 100644 --- a/synapse/http/proxy.py +++ b/synapse/http/proxy.py @@ -262,7 +262,8 @@ def connectionLost(self, reason: Failure = connectionDone) -> None: self._request.finish() else: # Abort the underlying request since our remote request also failed. - self._request.transport.abortConnection() + if self._request.channel: + self._request.channel.forceAbortClient() class ProxySite(Site): diff --git a/synapse/http/server.py b/synapse/http/server.py index 632284712c..c76500e14f 100644 --- a/synapse/http/server.py +++ b/synapse/http/server.py @@ -153,9 +153,9 @@ def return_json_error( # Only respond with an error response if we haven't already started writing, # otherwise lets just kill the connection if request.startedWriting: - if request.transport: + if request.channel: try: - request.transport.abortConnection() + request.channel.forceAbortClient() except Exception: # abortConnection throws if the connection is already closed pass diff --git a/synapse/http/site.py b/synapse/http/site.py index 682b28e4c6..a5b5780679 100644 --- a/synapse/http/site.py +++ b/synapse/http/site.py @@ -150,7 +150,8 @@ def handleContentChunk(self, data: bytes) -> None: self.get_method(), self.get_redacted_uri(), ) - self.transport.abortConnection() + if self.channel: + self.channel.forceAbortClient() return super().handleContentChunk(data) From ac0ac92e53d86a69eda1aceb21b3712e0906e4ad Mon Sep 17 00:00:00 2001 From: Erik Johnston Date: Wed, 27 Mar 2024 16:55:28 +0000 Subject: [PATCH 2/2] Newsfile --- changelog.d/17036.misc | 1 + 1 file changed, 1 insertion(+) create mode 100644 changelog.d/17036.misc diff --git a/changelog.d/17036.misc b/changelog.d/17036.misc new file mode 100644 index 0000000000..3296668059 --- /dev/null +++ b/changelog.d/17036.misc @@ -0,0 +1 @@ +Fix mypy with latest Twisted release.