Keep pooled live snapshots alive when a caller disconnects #137

Closed
opened 2026-08-06 20:49:18 +00:00 by rockachopa · 0 comments
Member

Problem

/api/v1/live pools simultaneous Gitea fan-out in one asyncio task, but each request awaits that shared task through asyncio.wait_for. A timed-out or disconnected caller therefore cancels the task for every attached mobile client, wastes the seven-request upstream fan-out, and can leak CancelledError instead of the bounded retry response introduced by #131.

Vertical slice

Make the shared snapshot own its deadline, shield it from individual request cancellation, and cancel/await active work during application shutdown before closing the pooled Gitea client.

Acceptance tests

  • Cancelling one of two attached callers leaves the snapshot running and the surviving caller receives 200; upstream fan-out starts once.
  • A task-owned deadline gives all attached callers the bounded 503 response without leaking CancelledError.
  • A request after completion or timeout starts one clean new snapshot.
  • Lifespan shutdown cancels and awaits active snapshot work before closing the Gitea transport.
  • Existing section degradation, no-store, and the full suite remain green.

Non-duplication evidence

All 72 historical issue titles and recent commits were reviewed. #131 added successful in-flight coalescing but has no cancellation/disconnect/shutdown coverage. No open issue or PR covers cancellation-safe pooled snapshots.

## Problem `/api/v1/live` pools simultaneous Gitea fan-out in one asyncio task, but each request awaits that shared task through `asyncio.wait_for`. A timed-out or disconnected caller therefore cancels the task for every attached mobile client, wastes the seven-request upstream fan-out, and can leak `CancelledError` instead of the bounded retry response introduced by #131. ## Vertical slice Make the shared snapshot own its deadline, shield it from individual request cancellation, and cancel/await active work during application shutdown before closing the pooled Gitea client. ## Acceptance tests - Cancelling one of two attached callers leaves the snapshot running and the surviving caller receives `200`; upstream fan-out starts once. - A task-owned deadline gives all attached callers the bounded `503` response without leaking `CancelledError`. - A request after completion or timeout starts one clean new snapshot. - Lifespan shutdown cancels and awaits active snapshot work before closing the Gitea transport. - Existing section degradation, `no-store`, and the full suite remain green. ## Non-duplication evidence All 72 historical issue titles and recent commits were reviewed. #131 added successful in-flight coalescing but has no cancellation/disconnect/shutdown coverage. No open issue or PR covers cancellation-safe pooled snapshots.
timmy was assigned by rockachopa 2026-08-06 20:49:18 +00:00
Sign in to join this conversation.
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: stackchain/stackchain-dashboard#137
No description provided.