Skip to content

fix: deploy-proof wallet path + self-healing stale tabs - #20

Merged
jayteemoney merged 1 commit into
mainfrom
fix/deploy-proof-wallet
Jul 13, 2026
Merged

fix: deploy-proof wallet path + self-healing stale tabs#20
jayteemoney merged 1 commit into
mainfrom
fix/deploy-proof-wallet

Conversation

@jayteemoney

Copy link
Copy Markdown
Owner

Root cause (final one)

"Module factory is not available" = a stale-bundle failure, not a wallet failure. The wallet library was loaded via dynamic import() — a lazy chunk fetched at click time. Every deploy replaces the content-hashed chunks, so any tab opened before a deploy breaks on the money path the moment the user clicks Connect. We deployed 3× in hours; every open visitor tab hit this.

The wiring (both layers root-cause)

  1. @stacks/connect imported statically — the wallet path ships in the initial bundle (~10 KB gz); there is no lazy chunk to lose, ever. Turbopack can't prerender the package's server module graph, so it's declared in serverExternalPackages (Node resolves it natively server-side — verified).
  2. StaleDeployGuard — global listeners detect missing-chunk errors anywhere (page route chunks too), and reload once onto the new build (sessionStorage loop protection). Wallet flows catch the same condition with a friendly "StackStream was updated — refreshing…" toast.

Verified on the production build

  • 13/13 pages prerender; landing, dashboard, earn, create all 200
  • Wallet code confirmed in the eager bundle; guard confirmed in bundle
  • API routes serving live mainnet data
  • typecheck + build clean

'Module factory is not available' — the wallet library was dynamically
imported, so it lived in a lazy chunk fetched at click time. Every
deploy replaces the hashed chunk files, so any tab opened before a
deploy lost the wallet chunk the moment the user clicked Connect. With
frequent deploys this broke the money path for every open tab.

Two layers, both root-cause:

- Import @stacks/connect statically (~10 KB gz) so the wallet path
  ships in the initial bundle and has no lazy chunk to lose. Turbopack
  cannot wire the package's server-side module graph during prerender,
  so it is declared in serverExternalPackages and resolved natively by
  Node on the server.
- StaleDeployGuard: global error/unhandledrejection listeners detect
  missing-chunk failures anywhere in the app (route chunks included)
  and reload once onto the new build, loop-protected via
  sessionStorage. Wallet flows additionally catch the same condition
  and reload with a friendly 'StackStream was updated' toast instead
  of surfacing module internals.

Verified on the production build: all 13 pages prerender, wallet code
present in the eager bundle, guard present, API routes serving.
@vercel

vercel Bot commented Jul 13, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
stackstream Ready Ready Preview, Comment Jul 13, 2026 8:13am

@jayteemoney
jayteemoney merged commit 882bc73 into main Jul 13, 2026
1 of 4 checks passed
@jayteemoney
jayteemoney deleted the fix/deploy-proof-wallet branch July 13, 2026 08:12
jayteemoney added a commit that referenced this pull request Jul 13, 2026
revert: deploy-proof wallet wiring (#20) — broke production client-side
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