Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Commit

Permalink
Catch AttributeErrors when calling registerProducer (#10995)
Browse files Browse the repository at this point in the history
Looks like the wrong exception type was caught in #10932.
  • Loading branch information
babolivier authored Oct 7, 2021
1 parent f563676 commit 52aefd5
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
1 change: 1 addition & 0 deletions changelog.d/10995.bugfix
Original file line number Diff line number Diff line change
@@ -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.
5 changes: 4 additions & 1 deletion synapse/http/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -563,7 +563,10 @@ def __init__(

try:
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)

# We drop our references to data we'll not use.
Expand Down

0 comments on commit 52aefd5

Please sign in to comment.