Catch AttributeErrors when calling registerProducer (#10995)

Looks like the wrong exception type was caught in #10932.
This commit is contained in:
Brendan Abolivier 2021-10-07 12:37:10 +02:00 committed by GitHub
parent f563676c09
commit 52aefd5086
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 1 deletions

1
changelog.d/10995.bugfix Normal file
View File

@ -0,0 +1 @@
Correct a bugfix introduced in Synapse v1.44.0 that wouldn't catch every error of the connection breaks before a response could be written to it.

View File

@ -563,7 +563,10 @@ class _ByteProducer:
try: try:
self._request.registerProducer(self, True) self._request.registerProducer(self, True)
except RuntimeError as e: except AttributeError as e:
# Calling self._request.registerProducer might raise an AttributeError since
# the underlying Twisted code calls self._request.channel.registerProducer,
# however self._request.channel will be None if the connection was lost.
logger.info("Connection disconnected before response was written: %r", e) logger.info("Connection disconnected before response was written: %r", e)
# We drop our references to data we'll not use. # We drop our references to data we'll not use.