Skip to content

ops: surface fetch errors in UI + log file (no more silent failures) #95

Closed

Description

@unhappychoice

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 and FetchError via .ok()?.ok()?:

    let payload = tokio::time::timeout(deadline, fetcher.fetch(&ctx))
        .await
        .ok()?  // Elapsed dropped silently
        .ok()?; // FetchError dropped silently
  • No logging infra — Cargo.toml pulls in neither log / 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.rs partial). 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.
  • 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

  1. 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.
  2. 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 can tail -f to debug their own dashboard.
  3. Consistency: one pattern across all fetchers. Either everyone returns Err and the runtime lifts it to a placeholder, or everyone returns Ok(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 CacheEntry and 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 prefers last_ok and overlays a small badge when last_err is newer. Better UX but requires a renderer-side compositor and a cache schema bump. Out of scope here; tracked as follow-up.
  • Tag the entry kind. Add a kind: CacheEntryKind { Ok, Err, Timeout } field on CacheEntry so 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 lift Err to a placeholder payload automatically (same treatment as the existing shape_mismatch_placeholder). Drop the per-fetcher Ok(placeholder(...)) helper.

  • Logging: add tracing + tracing-subscriber with a file appender. One-line structured log per failure (widget=<id> fetcher=<name> err=<msg>). A SPLASHBOARD_LOG=debug env switch for verbose mode.

  • Runtime lift: runtime.rs:555 becomes:

    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 existing placeholder() 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-appender wired up (file appender → $HOME/.splashboard/logs/splashboard.log)
  • SPLASHBOARD_LOG=debug / info / error respected
  • Log rotation or size cap (default: keep last 3 × 1 MiB, say)
  • CacheEntry gains a kind: 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 in fetcher/mod.rs)
  • Timeout becomes its own placeholder (⏱ timed out)
  • All Ok(placeholder(...)) call sites converted to return Err(FetchError::Failed(...)) (fewer lines, one pattern)
  • Tests: renderer shows the error text for a deliberately-failing fetcher; cache round-trips an Err kind; log line is written
  • Docs: "Debugging" cookbook page pointing at the log file

Out of scope

  • Variant B (two-slot last_ok + last_err cache + 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 logs subcommand — follow-up if people want it

Activity

  1. added
    ops
    feat
    on Apr 23, 2026
  2. added a commit that references this issue on Apr 24, 2026
    a9dcbb1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    featops

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions