Skip to content

[P0][bug] Daily Journal hangs on "Loading…" forever on a fresh empty DB (clean install, signed out) #1672

Description

@mstomar125

Summary

On a 100% clean install (fresh app + wiped ~/.nodespace + wiped webview localStorage + cleared keychain), signed out, empty Default DB: the Daily Journal (default view) hangs on "Loading…" forever. The daemon is healthy and answers CLI queries instantly; the sidebar renders; reload does not fix it. Reproduced deterministically in validation round-1 (2026-07-16), build core 330799b2 / sync 50ef06d.

This is unrelated to sync/consent/sign-in/cached state — a genuine build bug, and the "app looks broken on first launch" blocker.

Likely cause

A fresh DB has no date node for today (nodespace node query --type date → 0). The Daily-Journal load path appears to await a today-date-node that never arrives instead of auto-creating it / rendering an empty journal. Against an old DB that already had a date node, the journal rendered fine.

Fix direction

In the Daily-Journal load path (packages/desktop-app — viewers/date-node-viewer.svelte / journal store), auto-create today's date node on load (or render an empty-journal state); never block indefinitely.

Relation to #1644

The round-1 clean-room run did NOT reproduce a daemon crash-loop (single stable pid, clean log) — the permanent-"Loading" symptom that opened #1644 is this frontend hang (plus the sync-pull freeze, filed separately).

Evidence

Validation report val-loading-hang-FAIL.md (round-1 pack, 2026-07-16).

Activity

  1. self-assigned this
    on Jul 16, 2026
  2. mstomar125 commented on Jul 16, 2026

    @mstomar125
    ContributorAuthor

    Reopening — PR #1677 landed hardening for this (a pane-hydration retry + a persistent daemon-readiness poll), but the root cause of the fresh-install "Loading… forever" hang is not yet confirmed on a live device. The round-1 evidence ("reload does not fix it" + zero WatchNodes activity in the daemon log) is consistent with a failure at or below the app→daemon transport that a frontend re-invoke can't heal, so the hardening may not fully resolve the user-visible symptom.

    Keep open until the live fresh-install validation leg (round-2, on the validation Mac) confirms the journal renders on first launch of a clean install. If it does, close then; if it still hangs, the daemon-side transport is the next suspect (and #1678 tracks the related mid-session-restart signal gap).

  3. mstomar125 commented on Jul 17, 2026

    @mstomar125
    ContributorAuthor

    Root-cause narrowing (local physical-device session, 2026-07-17)

    Traced the full journal load path end-to-end. The frontend journal logic is correct — it does not explain an infinite "Loading…". The hang is below the webview, in the app's persistent gRPC client channel.

    What rules out the frontend logic:

    • On a fresh empty DB, ensureNode(today) synthesises a virtual date node when the backend returns nothing (shared-node-store.svelte.ts ensureNode, the isValidDateId branch), so the pane renders an empty journal — it does not wait forever for a node that never arrives.
    • The Rust get_node command maps gRPC NotFound → Ok(None) (src-tauri/src/commands/nodes.rs:371), so a missing today-date node resolves to null, not a thrown error. So the virtual-date-node fallback is reached on the happy path.

    Therefore an infinite "Loading…" against a healthy daemon can only come from the frontend's own gRPC call get_node(today) (distinct from the CLI path, which round-1 proved works):

    • (a) it throws a non-NotFound transport error on every attempt (channel never connects), or
    • (b) it never resolves (channel wedged).

    Both live in the managed GrpcClient channel (src-tauri/src/services/grpc_client.rs, connect_with_connector_lazy). This matches every round-1 observation:

    • "reload doesn't fix it" — a webview reload (Cmd-R) re-runs the Svelte app but does not recreate the Tauri-managed GrpcClient; only a full app restart does. A wedged channel survives Cmd-R.
    • "no WatchNodes activity" — a read-only path (get_node) that never reaches the daemon produces no domain-event traffic.
    • daemon answers CLI instantly — the daemon is healthy; the wedge is client-side.

    One specific mechanism is now backstopped: if the daemon's healthy transition is never observed by the frontend (the backend pushes daemon-status from its one-shot startup task before the webview registers its listener, and the single pull-on-subscribe caught starting), the pane's onDaemonReconnect retry never fires → wedged until an app restart. core#1678 (steady-state daemon-status poll, PR #1683) closes exactly this gap — a relaunched/late-healthy daemon is now re-observed and onDaemonReconnect re-fires.

    Definitive Bucket-A diagnostic for round 2 (real Tauri app, fresh install): reproduce the hang, then capture — in order:

    1. The diagnostic log for getNode (the app wraps it in withDiagnosticLogging; open the DeveloperInspector / DevTools console). Did get_node(today) throw (with which tonic Code?) or never return? This one signal splits (a) vs (b).
    2. Does a full app RESTART (not Cmd-R) clear it? Yes → wedged persistent channel (below the webview) → fix is channel-reconnect in grpc_client.rs. No → deeper.
    3. With [bug] daemon-status emits no healthy signal after a mid-session daemon restart — reconnect consumers never retry #1678 in the build, does the pane self-heal within ~15 s? Yes → the cause was the missed healthy transition and Harden pane hydration + poll daemon readiness until healthy (relates #1672) #1677+[bug] daemon-status emits no healthy signal after a mid-session daemon restart — reconnect consumers never retry #1678 resolve it (no further code needed).

    Keeping this OPEN until the live signal above disambiguates the fix. #1677 (retry-on-healthy) + #1678 (re-observe healthy) are the hardening; the remaining question is purely whether the persistent channel itself wedges.

  4. mstomar125 commented on Jul 17, 2026

    @mstomar125
    ContributorAuthor

    ✅ Validated FIXED on-device (round-2, 2026-07-17)

    Built a fresh Pro app from current main (core 4453d975 — includes #1677 + #1678; sync 021aef2) and ran the exact deterministic round-1 clean-room condition on the physical device:

    • wiped ~/.nodespace (kept only the embedding model) + cleared webview localStorage/caches + killed the detached daemon (it survives Cmd+Q), then cold-launched signed out on a fresh empty DB.

    Result: the Daily Journal renders today's date + a writeable node immediately — zero "Loading…", across 3 fresh launches including a genuine fresh daemon boot (pid changes; new empty daemon-pro-db). Daemon boot is clean every time — single stable pid, gRPC serving ~32 ms after start, 0 errors / 0 warns.

    The below-the-webview wedge did not occur (get_node(today) succeeded first-try each launch, so no retry was even needed). #1677 (retry-on-healthy) + #1678 (re-observe a missed/late healthy signal) close the boot-window path that hung deterministically in round 1.

    Incidental finding worth noting: the daemon is detached and survives app Cmd+Q — so a webview reload or app relaunch reuses the running daemon. That's consistent with round-1's "reload doesn't fix it": whatever channel state existed persisted across the reload. A fresh daemon boot (only reached by killing the daemon) now renders cleanly.

    Closing as fixed.

  5. mstomar125 commented on Jul 17, 2026

    @mstomar125
    ContributorAuthor

    Reopening — root cause CONFIRMED live (2026-07-17, round-2)

    The earlier fix (#1677 retry-on-healthy + #1678 steady-state poll) resolved the quiet-boot case (Section A: 3 clean launches). But the hang reproduced live in a way those don't cover, and it exposes the real mechanism.

    Repro: signed-in Pro daemon on a small tenant; the daemon did light sync activity (a membership-gain reconcile + WatchNodes churn), then the Daily Journal stuck on "Loading…".

    Definitive evidence — the daemon is healthy, the frontend channel is wedged:

    • Daemon idle (0% CPU), reconcile finished cleanly (caught up gained collections replayed=2), no reachability timeout, no re-pull.
    • A direct grpcurl NodeService/GetNode {node_id:"2026-07-17"} on the daemon socket returns today's date node fine — so the node exists and the daemon answers other clients.
    • Yet the frontend's own get_node(today) never resolves → isNodeHydrated stays false → "Loading…".

    ⟹ The frontend's persistent Tauri GrpcClient channel is wedged (its WatchNodes stream and unary calls share one h2 connection — src-tauri/src/watcher.rs: "rides the same h2 connection as every other data-plane request"). When the WatchNodes stream churns/breaks during sync, the shared channel wedges and subsequent unary calls (get_node) hang. #1677/#1678 don't recover it because the daemon never goes not-healthy — there is no health transition to fire onDaemonReconnect.

    Fix direction:

    1. Isolate the WatchNodes stream onto its own channel so a stream break can't wedge the unary/data-plane channel (cleanest), OR
    2. Recover on a wedged unary call — reset/recreate the GrpcClient channel when a get_node/write RPC fails or times out, independent of the daemon-health signal, OR
    3. give the pane a bounded self-retry that resets the channel (not just re-invokes on the same wedged one).

    Related live findings: the same channel-wedge mechanism starves writes under heavier sync (nodespace-sync#332); the reachability-timeout that triggered the heavy sync is fixed (nodespace-cloud#82), but a lighter WatchNodes churn still wedges the channel.

  6. mstomar125 commented on Aug 1, 2026

    @mstomar125
    ContributorAuthor

    Resolved in #1880 (merged).

    Root cause: the desktop app rides every service client + long-lived stream on one shared h2 channel. Heavy sync churn can wedge that connection — reads/writes and streams hang forever (the lazy channel has no client-side timeout) while the daemon socket stays healthy, so check_daemon_status keeps reporting healthy, onDaemonReconnect never fires, and the journal stays on "Loading…". Only a restart recovered it.

    Fix (self-heal in place, across every surface): the daemon-status steady-state poll now probes the real channel after a healthy status; a timeout means wedged → GrpcClient::reconnect() rebuilds the lazy channel + all service clients (preserving DB routing + client_id), bumps db_generation so the node watcher re-opens its stream, and re-fires reconnect listeners so panes re-fetch. The ai-chat token stream now interrupts on db_generation and re-subscribes; ProClient::rebind() re-points cloud-sync calls at the fresh channel.

    Follow-up: the Pro live-status WatchSyncStatus stream auto-respawn (a coordinated task-interrupt + STREAM_SPAWNED reset + frontend re-subscribe) is tracked in #1879.

    Validated: full pre-push gate green (frontend 4098 tests incl. the new wedge-recovery poll test, Rust workspace, e2e round-trip, Tauri-seam ADR-048). The live timing-dependent wedge is hard to force deterministically; the recovery path is covered by the unit test and mirrors the proven node-watcher pattern.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions