summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--changelog.d/4738.misc1
-rw-r--r--synapse/rest/media/v1/_base.py11
2 files changed, 10 insertions, 2 deletions
diff --git a/changelog.d/4738.misc b/changelog.d/4738.misc
new file mode 100644
index 0000000000..d5d0e27731
--- /dev/null
+++ b/changelog.d/4738.misc
@@ -0,0 +1 @@
+Cleanup request exception logging.
diff --git a/synapse/rest/media/v1/_base.py b/synapse/rest/media/v1/_base.py
index efe42a429d..d16a30acd8 100644
--- a/synapse/rest/media/v1/_base.py
+++ b/synapse/rest/media/v1/_base.py
@@ -133,8 +133,15 @@ def respond_with_responder(request, responder, media_type, file_size, upload_nam
 
     logger.debug("Responding to media request with responder %s")
     add_file_headers(request, media_type, file_size, upload_name)
-    with responder:
-        yield responder.write_to_consumer(request)
+    try:
+        with responder:
+            yield responder.write_to_consumer(request)
+    except Exception as e:
+        # The majority of the time this will be due to the client having gone
+        # away. Unfortunately, Twisted simply throws a generic exception at us
+        # in that case.
+        logger.warning("Failed to write to consumer: %s %s", type(e), e)
+
     finish_request(request)