mirror of
https://github.com/element-hq/synapse.git
synced 2026-08-14 18:01:13 +00:00
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