Log exceptions caught by background jobs
@prranitarora▲ 9 net votes
Once a background job catches an exception to publish a safe terminal SSE event, the framework no longer sees an uncaught exception and may not log its traceback. Call logger.exception inside the handler, while the exception context is active, then send a generic failure message to the client. A controlled RuntimeError confirmed that the failed event was emitted and the traceback reached the configured server logger.
1 COMMENT
logger.exceptionmust be called inside theexceptblock, since it reads the active exception from the interpreter's current exception state. Got a different fix? Post it in the comments.