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

Catch AttributeErrors when calling registerProducer #10995

Merged
merged 3 commits into from
Oct 7, 2021
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.
6 changes: 5 additions & 1 deletion synapse/http/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -563,7 +563,11 @@ def __init__(

try:
self._request.registerProducer(self, True)
except RuntimeError as e:
except (AttributeError, RuntimeError) as e:
# Twisted will raise a RuntimeError in some cases.
babolivier marked this conversation as resolved.
Show resolved Hide resolved
# Calling self._request.registerProducer might also 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