From 32bfe5f129117315fb8650a11847837cc462165b Mon Sep 17 00:00:00 2001 From: timedout Date: Tue, 17 Nov 2026 09:26:22 +0000 Subject: [PATCH] fix: Allow sync v2 to be interrupted by server shutdown Fixes #2361 --- src/api/client/sync/v3/mod.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/api/client/sync/v3/mod.rs b/src/api/client/sync/v3/mod.rs index f970c6541..e004ec08d 100644 --- a/src/api/client/sync/v3/mod.rs +++ b/src/api/client/sync/v3/mod.rs @@ -225,7 +225,11 @@ pub(crate) async fn sync_events_route( // seconds (this isn't specced, but a reasonable cap since most clients have // a 30-second polling interval). let duration = timeout_duration.min(Duration::from_secs(30)); - _ = tokio::time::timeout(duration, wake_receiver.changed()).await; + let mut shutdown_signal = services.server.signal.subscribe(); + tokio::select! { + _ = tokio::time::timeout(duration, wake_receiver.changed()) => {}, + _ = shutdown_signal.recv() => return Err!(Request(Unknown("Server is shutting down"), SERVICE_UNAVAILABLE)), + }; // Retry returning data build_sync_events(&services, &body).await