From 1a850b025623ef4f90d87e2815395ec1f12ca555 Mon Sep 17 00:00:00 2001 From: Job Evers-Meltzer Date: Tue, 17 Jan 2017 20:01:04 -0600 Subject: [PATCH 1/2] log exception on callback failure --- lbrynet/core/log_support.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/lbrynet/core/log_support.py b/lbrynet/core/log_support.py index 59b06b4b0..e4f7d64df 100644 --- a/lbrynet/core/log_support.py +++ b/lbrynet/core/log_support.py @@ -399,7 +399,16 @@ class Logger(logging.Logger): self.name, level, fn, lno, msg, msg_args, exc_info, func, msg_kwargs) self.handle(record) if callback: - return callback(err, *args, **kwargs) + try: + return callback(err, *args, **kwargs) + except Exception: + # log.fail is almost always called within an + # errback. If callback fails and we didn't catch + # the exception we would need to attach a second + # errback to deal with that, which we will almost + # never do and then we end up with an unhandled + # error that will get swallowed by twisted + self.exception('Failed to run callback') return _fail def trace(self, msg, *args, **kwargs): From 13bfcb3561a5cd1c4f786d08358cf143cfee3a1a Mon Sep 17 00:00:00 2001 From: Job Evers-Meltzer Date: Tue, 17 Jan 2017 20:01:28 -0600 Subject: [PATCH 2/2] fix missing id_ parameter to _render_error --- lbrynet/lbrynet_daemon/auth/server.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lbrynet/lbrynet_daemon/auth/server.py b/lbrynet/lbrynet_daemon/auth/server.py index 1dad890b7..136cd3b49 100644 --- a/lbrynet/lbrynet_daemon/auth/server.py +++ b/lbrynet/lbrynet_daemon/auth/server.py @@ -211,7 +211,7 @@ class AuthJSONRPCServer(AuthorizedBase): # handle deferredLists that won't peacefully cancel, namely # get_lbry_files d.addErrback(trap, ConnectionDone, ConnectionLost, defer.CancelledError, RuntimeError) - d.addErrback(log.fail(self._render_error, request, version=version), + d.addErrback(log.fail(self._render_error, request, id_, version=version), 'Failed to process %s', function_name) d.addBoth(lambda _: log.debug("%s took %f", function_name,