Skip to content

fix(web): sign-in and writes hang when another tab holds old storage; bound every sign-in wait - #79

Merged
PastaPastaPasta merged 2 commits into
masterfrom
fix/signin-spinner-timeouts
Sep 27, 2026
Merged

PastaPastaPasta merged 2 commits into
masterfrom
fix/signin-spinner-timeouts

Conversation

@PastaPastaPasta

Copy link
Copy Markdown
Owner

Summary

Owner S1 reports:

  1. "Sign in → Create" showed a bare spinner under "Forge signs with a limited key…" and never moved.
  2. Import → "Create this browser's key" (with a passkey and private repos on) spun forever after the group check. Nothing was broadcast.
  3. /new "Sign & create" spun with no broadcast.

Root cause (one cause for all three)

A second Dash Forge tab is holding the dash-forge IndexedDB open at an older version, so the upgrade is blocked. The owner's tab strip shows a second forge tab.

  • 660d5a1 raised DB_VERSION from 1 to 2 (the inbox store). A tab still running an older build keeps the database open at v1 and never releases it: that build has no onversionchange handler.
  • The new build's lib/idb.ts rejected on onblocked and then dropped the blocked request. Every later indexedDB.open(v2) queued behind the blocked upgrade and never fired any event.
  • As a result, every IndexedDB read and write in the new tab hung until the old tab was closed or reloaded. That covers:
    • Create's first step (the creation journal);
    • Import's listVaults(), which runs before its first Platform call;
    • createRepo's journal.
  • The network traces match. In the owner's Import trace, every request is the sheet's mount-time group check, and nothing at all happens after the click. On chain, the owner's identity 47h9EpDd… still has only keys 0–4, so nothing was written and there is nothing to recover or double-register.

Reproduction (Playwright)

Other suspects were ruled out. None of them reproduces the hang:

  • DAPI or the quorum endpoint hanging: Create doesn't need the network.
  • Slow 3G: loads slowly, but doesn't hang.

Two of the injections I tried also leave a bare spinner forever, a secondary issue:

  • blocking or hanging the evo-sdk chunk;
  • the wallet tile's connect hanging.

Fix

  • lib/idb.ts:
    • keeps the one pending open instead of abandoning it;
    • while it is blocked, callers get a named error at once: "Dash Forge is open in another tab running an older version… close or reload it, then try again";
    • every open is capped at 10 s;
    • "Try again" succeeds once the other tab is gone.
    • On onversionchange, a tab closes its connection and shows a "Dash Forge was updated in another tab — Reload" banner (components/storage-updated.tsx), so future upgrades are never blocked by a current build.
  • No sign-in wait is unbounded any more:
    • lib/timeout.ts adds withTimeout;
    • lib/auth/connect.ts bounds the evo-sdk download plus wasm init (5 min cap for slow links) and the connect (20 s), each with a named error;
    • Create, Wallet and the wallet-tile availability check show what they are waiting for, with elapsed seconds, and end in a named error with Try again;
    • the controller's SDK provider uses the bounded connect, so Import, Advanced and Unlock fail with "Could not connect to Dash Platform (…)" instead of spinning;
    • Import's button names each step: "Checking this browser's stored keys…", "Connecting to Dash Platform…", "Registering the key on Platform…", "Saving the key with your passkey…", "Enabling private repos…";
    • the passkey WebAuthn ceremonies are bounded, and a failure says to use a passphrase instead.
  • Writer lock (lib/sdk/write.ts serialized): waiting for this identity's writer lock is bounded to 3 min. That covers both this tab's queue and the cross-tab Web Lock, which is aborted through AbortSignal. A waiter that gives up gets "Another Dash Forge tab … is still finishing a write for this identity" and never runs. A write that already holds the lock is not cut off.
  • Security: the Advanced pasted private key was a controlled type=password input outside any <form>. React mirrored the key into the DOM value attribute, and Chrome's "[DOM] Password field is not contained in a form" warning can print that element. The key and the vault passphrases are now uncontrolled inputs inside forms, and the key is cleared after use.

Coordination

  • The lib/sdk service internals (wasm progress, connect timeout, auto-retry) are owned by the network-resilience work. This PR only wraps ensureSdk from the outside, so a retry joins the in-flight connect.
  • serialized() is the one lib/sdk change.

Cites: D-013, D-024, D-025 and D-058 (related hang classes, not fixed here), and the owner reports above.

Tests

  • e2e/signin-resilience.spec.ts runs in Chromium and WebKit (a new webkit project scoped to this spec). All 12 runs pass on this branch. All 6 specs fail on master in Chromium; s1–s3, the ones run there, fail on master in WebKit too.

    Spec What it checks
    s1 An old tab blocks the storage upgrade: Create shows a named error, then recovers with Try again.
    s2 The evo-sdk chunk is blocked: Create and Wallet show a named error, and Try again recovers.
    s3 DAPI and the quorum endpoint hang: Create, Import, Wallet and Advanced each reach content or a named error within the timeout.
    s4 The owner's second report: Import with private repos on and an old tab gives a named error, with no broadcast.
    s5 A pasted key is never in the page HTML, and no password field sits outside a form.
    s6 When a newer tab upgrades storage, it is not blocked, and this tab shows the reload banner.
  • Unit tests:

    • lib/timeout.test.ts;
    • lib/sdk/writer-lock.test.ts: waiters behind a stuck in-tab write or a stuck cross-tab Web Lock give up and never run, while a lock holder is not cut off. The two give-up tests fail on master.
  • pnpm test: 1540 passed. pnpm typecheck and pnpm lint are clean.

Workaround until this deploys: close or reload every other forge.dashhq.org tab, then retry.

🤖 Generated with Claude Code

PastaPastaPasta and others added 2 commits September 27, 2026 11:25
…orage upgrade

An old Dash Forge tab holding the dash-forge IndexedDB at v1 blocked the v2 upgrade; idb.ts dropped the blocked open and every later open queued behind it without firing, so Create, Import and every write that touches IndexedDB waited forever. Keep the one pending open, fail fast with a named error while blocked, and cap the open at 10 s. Bound the SDK download, connect and passkey ceremonies in the sign-in sheet, with named errors and Try again.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
…s kept out of the DOM

A write waiting for this identity's writer lock (this tab's queue or the cross-tab Web Lock) now gives up after 3 minutes with a named error instead of waiting forever behind a stuck holder. A tab whose storage a newer build upgrades closes its connection and shows a reload banner. Import names each step on its button. The pasted private key and passphrases are uncontrolled inputs inside forms, so they never appear in a value attribute or in Chrome's console warning.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
@coderabbitai

coderabbitai Bot commented Sep 27, 2026

Copy link
Copy Markdown

Warning

Review limit reached

Next included review available in 32 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Learn how review limits work.

Review configuration:

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Advanced

Run ID: 52635b6e-ba80-4e41-bd6f-a52d3e3fd19a

📥 Commits

Reviewing files that changed from the base of the PR and between 1c3418f and 2f7eed7.

📒 Files selected for processing (19)
  • forge-web/components/app-shell.tsx
  • forge-web/components/auth/create-identity-flow.tsx
  • forge-web/components/auth/protection-fields.tsx
  • forge-web/components/auth/step-status.tsx
  • forge-web/components/auth/wallet-connect-flow.tsx
  • forge-web/components/login-modal.tsx
  • forge-web/components/storage-updated.tsx
  • forge-web/contexts/auth-context.tsx
  • forge-web/e2e/signin-resilience.spec.ts
  • forge-web/lib/auth/connect.ts
  • forge-web/lib/auth/controller.ts
  • forge-web/lib/auth/hd.ts
  • forge-web/lib/auth/vault.ts
  • forge-web/lib/idb.ts
  • forge-web/lib/sdk/write.ts
  • forge-web/lib/sdk/writer-lock.test.ts
  • forge-web/lib/timeout.test.ts
  • forge-web/lib/timeout.ts
  • forge-web/playwright.config.ts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant