Update check caches "context canceled" for 24h when the triggering page view is aborted #724

Closed
opened 2026-09-24 22:28:27 +00:00 by Cordy · 0 comments
Owner

Observed

On files-bao (v0.6.266), Administration → Updates showed:

Update check failed: Get "http://192.168.10.245/api/v1/repos/Cordy/Cairn/tags": context canceled

…while simultaneously reporting "Checked 21 seconds ago" and current = latest = v0.6.266. The feed was reachable the whole time.

Root cause

adminUpdates calls uc.result(r.Context(), force), so the on-demand upstream tags fetch runs on the browser request's own context. When that request dies before the fetch completes (navigation to another admin section, closed tab, aborted fetch), Go cancels the context mid-flight, the fetch fails with context canceled, and refresh() caches that string as lastErr with a fresh checkedAt. The cache is considered fresh for 24h, so every later page view serves the stale failure banner without re-checking.

The daily pollLoop is unaffected (it uses context.Background() + 30s); only the on-demand path inherits the client's context. The retained-last-good-tag behaviour explains why the banner coexists with a correct version comparison.

At a customer this reads as "my server cannot reach the update feed" for up to a day after one impatient page navigation.

Fix

  • result(): detach the upstream fetch from the client — context.WithTimeout(context.WithoutCancel(ctx), 30s). A cache refresh should not be aborted (let alone recorded as failed) because the viewer clicked away.
  • Belt-and-braces in refresh(): a context.Canceled error records nothing — it is news about the caller, not the feed.

One file (internal/api/updates.go) + a regression test alongside updates_cache_test.go.

## Observed On files-bao (v0.6.266), Administration → Updates showed: > Update check failed: Get "http://192.168.10.245/api/v1/repos/Cordy/Cairn/tags": context canceled …while simultaneously reporting "Checked 21 seconds ago" and current = latest = v0.6.266. The feed was reachable the whole time. ## Root cause `adminUpdates` calls `uc.result(r.Context(), force)`, so the on-demand upstream tags fetch runs on the **browser request's own context**. When that request dies before the fetch completes (navigation to another admin section, closed tab, aborted fetch), Go cancels the context mid-flight, the fetch fails with `context canceled`, and `refresh()` caches that string as `lastErr` with a fresh `checkedAt`. The cache is considered fresh for 24h, so every later page view serves the stale failure banner without re-checking. The daily `pollLoop` is unaffected (it uses `context.Background()` + 30s); only the on-demand path inherits the client's context. The retained-last-good-tag behaviour explains why the banner coexists with a correct version comparison. At a customer this reads as "my server cannot reach the update feed" for up to a day after one impatient page navigation. ## Fix - `result()`: detach the upstream fetch from the client — `context.WithTimeout(context.WithoutCancel(ctx), 30s)`. A cache refresh should not be aborted (let alone recorded as failed) because the viewer clicked away. - Belt-and-braces in `refresh()`: a `context.Canceled` error records nothing — it is news about the caller, not the feed. One file (`internal/api/updates.go`) + a regression test alongside `updates_cache_test.go`.
Cordy closed this issue 2026-09-24 22:45:33 +00:00
Sign in to join this conversation.
No labels
No project
No assignees
1 participant
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: Cordy/Cairn#724
No description provided.