From df2cfb393211ef5ed0c81eadf2283ecc1ac98379 Mon Sep 17 00:00:00 2001 From: Eric Eastwood Date: Wed, 27 Aug 2025 11:25:57 -0500 Subject: [PATCH] Link upstream Twisted bug: Idle connection timeout incorrectly enforced while sending large response with `Request.write(...)` (#18855) Link upstream Twisted bug -> https://github.com/twisted/twisted/issues/12498 Spawning from https://github.com/element-hq/synapse/pull/18852 --- changelog.d/18855.misc | 1 + synapse/http/server.py | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) create mode 100644 changelog.d/18855.misc diff --git a/changelog.d/18855.misc b/changelog.d/18855.misc new file mode 100644 index 000000000..6f87c4ef2 --- /dev/null +++ b/changelog.d/18855.misc @@ -0,0 +1 @@ +Link [upstream Twisted bug](https://github.com/twisted/twisted/issues/12498) tracking the problem that explains why we have to use a `Producer` to write bytes to the request. diff --git a/synapse/http/server.py b/synapse/http/server.py index f8f58ec6d..45c74d68f 100644 --- a/synapse/http/server.py +++ b/synapse/http/server.py @@ -913,8 +913,9 @@ def _write_bytes_to_request(request: Request, bytes_to_write: bytes) -> None: # once (via `Request.write`) is that doing so starts the timeout for the # next request to be received: so if it takes longer than 60s to stream back # the response to the client, the client never gets it. + # c.f https://github.com/twisted/twisted/issues/12498 # - # The correct solution is to use a Producer; then the timeout is only + # One workaround is to use a `Producer`; then the timeout is only # started once all of the content is sent over the TCP connection. # To make sure we don't write all of the bytes at once we split it up into