summary refs log tree commit diff
diff options
context:
space:
mode:
authorKegan Dougal <kegan@matrix.org>2014-08-19 10:55:44 +0100
committerKegan Dougal <kegan@matrix.org>2014-08-19 10:56:43 +0100
commitf48792eec43f893f4f893ffdcbf00f8958b6f6b5 (patch)
tree850e959cfb47f5d51f4cd26feb70a0a051332f6b
parentChange mouse cursor to pointer on elements user can click on (diff)
downloadsynapse-f48792eec43f893f4f893ffdcbf00f8958b6f6b5.tar.xz
Reduce the amount of incredibly spammy stack traces. Expected errors (e.g. SynapseErrors) shouldn't have their full trace logged every time. Don't send responses to disconnected requests.
-rw-r--r--synapse/http/server.py14
1 files changed, 13 insertions, 1 deletions
diff --git a/synapse/http/server.py b/synapse/http/server.py
index 42fb9f5e96..c28d9a33f9 100644
--- a/synapse/http/server.py
+++ b/synapse/http/server.py
@@ -132,7 +132,11 @@ class JsonResource(HttpServer, resource.Resource):
                 {"error": "Unrecognized request"}
             )
         except CodeMessageException as e:
-            logger.exception(e)
+            if isinstance(e, SynapseError):
+                logger.error("%s SynapseError: %s - %s", request, e.code,
+                             e.msg)
+            else:
+                logger.exception(e)
             self._send_response(
                 request,
                 e.code,
@@ -147,6 +151,14 @@ class JsonResource(HttpServer, resource.Resource):
             )
 
     def _send_response(self, request, code, response_json_object):
+        # could alternatively use request.notifyFinish() and flip a flag when
+        # the Deferred fires, but since the flag is RIGHT THERE it seems like
+        # a waste.
+        if request._disconnected:
+            logger.warn(
+                "Not sending response to request %s, already disconnected.",
+                request)
+            return
 
         if not self._request_user_agent_is_curl(request):
             json_bytes = encode_canonical_json(response_json_object)