Description
Problem
Fetch failures today are silent. If a fetcher returns Err(FetchError::Failed(...)) — or times out — the widget just never updates. Nothing is shown to the user, nothing is written to a log. Debugging "why is this widget blank?" requires running a REPL-style cargo run with dbg! inserted.
Concrete spots where errors are swallowed today:
-
src/runtime.rs:555-558— the main fetch dispatch discards both the timeout error andFetchErrorvia.ok()?.ok()?:let payload = tokio::time::timeout(deadline, fetcher.fetch(&ctx)) .await .ok()? // Elapsed dropped silently .ok()?; // FetchError dropped silently
-
No logging infra —
Cargo.tomlpulls in neitherlog/tracing/env_logger/tracing-subscriber. There's nowhere for a fetcher to write "I tried, I failed, here's why." -
Fetchers split into two error styles, inconsistent:
- Some return
Ok(placeholder("..."))with the reason baked into the Text body (github/action_status.rs,weather.rs,read_store.rspartial). These do render something visible — a⚠ …line. - Others return
Err(FetchError::Failed(...))(weather.rs:123/126/131,avatar.rs:112/115/120/126,client.rs:40,contributions.rs:140, many more). These all get dropped at the runtime boundary above.
- Some return
-
The daemon (
src/daemon.rs) runs fetches in the background. It has the same silent-drop behavior and no logging sink.
Net effect: a cached widget that fails mid-refresh will keep serving stale cache until TTL expires; a first-run widget that fails will just render the empty-state placeholder forever.
Goals
- UI: every fetch failure surfaces as a visible placeholder in the widget's slot — one-line reason, icon (
⚠), consistent with the existing "unknown fetcher" / "shape mismatch" / "🔒 requires trust" placeholders. No blank widgets. - Log file: structured log at
$HOME/.splashboard/logs/splashboard.log(rotated or capped size) with timestamp, widget id, fetcher name, cache key, error chain. Something a user cantail -fto debug their own dashboard. - Consistency: one pattern across all fetchers. Either everyone returns
Errand the runtime lifts it to a placeholder, or everyone returnsOk(placeholder)and the call sites can stop caring. Pick one.
Proposed scope
-
Persist errors through the cache. The daemon runs fetches in the background — if we only build an error placeholder at fetch time and drop it, the next main-process invocation just reads the last successful
CacheEntryand shows nothing wrong. The failure has to land in the cache so the next render sees it. Two variants considered:- A. Overwrite-with-error (simpler, picked): on failure, the daemon writes
CacheEntry::new(error_placeholder, error_ttl)with a short TTL (say 30–60s, vs 5min default) so a transient blip doesn't pin the widget on⚠for long. Downside: last-good payload is lost the moment anything fails. - B. Two-slot entry (
last_ok+last_err): renderer preferslast_okand overlays a small badge whenlast_erris newer. Better UX but requires a renderer-side compositor and a cache schema bump. Out of scope here; tracked as follow-up.
- A. Overwrite-with-error (simpler, picked): on failure, the daemon writes
-
Tag the entry kind. Add a
kind: CacheEntryKind { Ok, Err, Timeout }field onCacheEntryso rendering / diagnostics can tell the difference without sniffing the payload body. Cheap to add now, opens the door to variant B later. -
Unify the error surface: fetchers just
return Err(FetchError::Failed(...)); the runtime / daemon liftErrto a placeholder payload automatically (same treatment as the existingshape_mismatch_placeholder). Drop the per-fetcherOk(placeholder(...))helper. -
Logging: add
tracing+tracing-subscriberwith a file appender. One-line structured log per failure (widget=<id> fetcher=<name> err=<msg>). ASPLASHBOARD_LOG=debugenv switch for verbose mode. -
Runtime lift:
runtime.rs:555becomes:match tokio::time::timeout(deadline, fetcher.fetch(&ctx)).await { Ok(Ok(p)) => Some((id, cache_key, ttl, CacheEntryKind::Ok, p)), Ok(Err(e)) => { log_fetch_err(&id, &fetcher_name, &e); Some((id, cache_key, err_ttl, CacheEntryKind::Err, error_placeholder(&e))) } Err(_) => { log_fetch_timeout(&id, &fetcher_name); Some((id, cache_key, err_ttl, CacheEntryKind::Timeout, timeout_placeholder())) } }
The tuple still flows through
c.store(&key, &CacheEntry::new_with_kind(...))so the cache carries the failure across runs. -
Placeholder shape: reuse the
⚠ <msg>convention from existingplaceholder()helpers. Two-line when the message is long (truncate/wrap rule TBD). -
Daemon: same lift + same log + same cache write. The daemon is the primary source of background failures — these need to land in both the log and the cache so "the splash never refreshes" doesn't stay mysterious on the next render.
Definition of Done
-
tracing+tracing-appenderwired up (file appender →$HOME/.splashboard/logs/splashboard.log) -
SPLASHBOARD_LOG=debug/info/errorrespected - Log rotation or size cap (default: keep last 3 × 1 MiB, say)
-
CacheEntrygains akind: CacheEntryKind { Ok, Err, Timeout }field (backwards-compatible deserialize: missing =Ok) - Daemon writes failed fetches to the cache with a short
error_ttl(default ~30s) so the next render sees the⚠instead of stale success data - Runtime / daemon lift
Err→ error placeholder payload (one helper infetcher/mod.rs) - Timeout becomes its own placeholder (
⏱ timed out) - All
Ok(placeholder(...))call sites converted toreturn Err(FetchError::Failed(...))(fewer lines, one pattern) - Tests: renderer shows the error text for a deliberately-failing fetcher; cache round-trips an
Errkind; log line is written - Docs: "Debugging" cookbook page pointing at the log file
Out of scope
- Variant B (two-slot
last_ok+last_errcache + renderer-side badge compositor) — tracked as a follow-up once variant A ships and we know if the UX feels too jittery - Panic hook / backtrace capture — separate concern, can land later
- Telemetry / remote error reporting — not ever, splashboard is offline-first
- Retry/backoff policy changes — the existing TTL is the retry cadence; this issue is about surfacing failures, not recovering from them
- Log-file viewer UI /
splashboard logssubcommand — follow-up if people want it
Activity
docs(fetcher): freshen stale 'placeholder' wording after #95 runtime …
Merge pull request #103 from unhappychoice/feat/surface-fetch-errors