Skip to content

Fix: bound the batched polls separately and show a failed badge as stale - #48

Merged
SandObserver merged 1 commit into
mainfrom
fix/badge-batch-timeout
Aug 12, 2026
Merged

SandObserver merged 1 commit into
mainfrom
fix/badge-batch-timeout

Conversation

@SandObserver

Copy link
Copy Markdown
Owner

Summary

  • Add BATCH_MS (2500ms) and use it for the per-item requests in the /api/badges and /api/health fan-outs, so one hung service no longer holds the whole batch for PING_MS.
  • Keep PING_MS for /api/badge-test and the version check, which a user runs by hand and waits on.
  • Add readBadgeUpdate to badge-logic.js, which reads one item's entry as a value or a failure rather than trusting value alone.
  • Keep an item's last known badge value when its own fetch failed and mark it stale through a new activityStale input to computeBadgeVisual, reusing the existing status.stale string.
  • Document the two deadlines and the per-item failure handling in docs/frontend.md.

Note on the shape of this fix. The tradeoff was between tightening what exists and building a real per-item state machine with server-side result caching. I took the smaller one: the cost of a dead service is a timeout that was simply too long for a background poll, and the misleading zero was information the server already sent and the frontend threw away. Caching results server-side would mean long-lived state in a project that deliberately has none, for a problem that turned out to be two small ones.

Testing
All green, apart from the Docker build smoke test, which needs a local Docker daemon. Added 2 route tests, including one proving a hung service no longer costs the batch its old deadline, and 5 frontend tests for reading a failed item and marking it stale.

Checklist

  • Stays within the project constraints: one container, no runtime dependencies, no build step (see CONTRIBUTING.md).
  • Tests added or updated for new logic, and the full suite, lint, and typechecks pass.
  • Docs updated if behavior or configuration changed.
  • CHANGELOG.md updated under Unreleased if the change is user-visible.

/api/badges and /api/health answer only once every item has settled, so
one dead service added its full 6s timeout to every tile's refresh. Give
the batched fan-outs their own 2.5s deadline and keep PING_MS for a
single connection test a user waits on.

The badges route already reports a per-item error, which the dashboard
discarded, painting a service that never answered as no badge at all.
Keep the last known value and mark it out of date instead.
@SandObserver SandObserver added the bug Something isn't working label Aug 12, 2026
@SandObserver
SandObserver merged commit 8a7b39d into main Aug 12, 2026
4 checks passed
@SandObserver
SandObserver deleted the fix/badge-batch-timeout branch August 12, 2026 22:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant