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

Commit

Permalink
Reduce the amount of incredibly spammy stack traces. Expected errors …
Browse files Browse the repository at this point in the history
…(e.g. SynapseErrors) shouldn't have their full trace logged every time. Don't send responses to disconnected requests.
  • Loading branch information
kegsay committed Aug 19, 2014
1 parent 509ce6c commit f48792e
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion synapse/http/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,11 @@ def _async_render(self, request):
{"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,
Expand All @@ -147,6 +151,14 @@ def _async_render(self, request):
)

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)
Expand Down

0 comments on commit f48792e

Please sign in to comment.