Files
synapse/rust
Erik JohnstonandClaude Fable 5 62e4b39cc1 Fix the logcontext restore protocol in run_python_awaitable
Two fixes to the `starter` closure that drives a Python awaitable on the
reactor thread on behalf of a tokio task:

- Run the fallible `run_in_background`/`addCallbacks` section inside a
  closure so an error can no longer skip the restore: previously the `?`
  returned early and permanently leaked the restored context onto the
  reactor thread, misattributing all subsequent reactor work.

- Don't restore a context that has already finished (the request completed
  or was cancelled while the task was still running — `create_deferred`
  does not propagate cancellation). Doing so tripped the 'Re-starting
  finished log context' abuse check and accounted work against a context
  whose metrics were already finalised; run in the reactor's current
  context (normally the sentinel) instead, as the pre-port code did.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JFbRtswu7rsHrttJFauUUb
2026-07-16 15:05:27 +00:00
..