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

Commit

Permalink
Fix exception responding to request that has been closed
Browse files Browse the repository at this point in the history
Introduced in #10905
  • Loading branch information
erikjohnston committed Sep 28, 2021
1 parent a8bbf08 commit 2cf92c9
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions synapse/http/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -561,9 +561,17 @@ def __init__(
self._iterator = iterator
self._paused = False

# Register the producer and start producing data.
self._request.registerProducer(self, True)
self.resumeProducing()
try:
self._request.registerProducer(self, True)
except RuntimeError as e:
logger.info("Connection disconnected before response was written: %r", e)

# We drop our references to data we'll not use.
self._request = None
self._iterator = iter(())
else:
# Start producing if `registerProducer` was successful
self.resumeProducing()

def _send_data(self, data: List[bytes]) -> None:
"""
Expand Down

0 comments on commit 2cf92c9

Please sign in to comment.