fix: Allow sync v2 to be interrupted by server shutdown

Fixes #2361
This commit is contained in:
timedout committed 2026-11-17 09:26:22 +00:00
1 parent 07d4c6f304
commit 32bfe5f129
1 file changed
+5 -1
+5 -1
View File
@@ -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