Skip to content

wallet: in debug mode, do not tell the wallet where to send the user back to - #41

Merged
ehsan6sha merged 1 commit into
mainfrom
wallet/debug-no-redirect
Sep 5, 2026
Merged

wallet: in debug mode, do not tell the wallet where to send the user back to#41
ehsan6sha merged 1 commit into
mainfrom
wallet/debug-no-redirect

Conversation

@ehsan6sha

Copy link
Copy Markdown
Member

A diagnostic, not a feature. Default behaviour is unchanged.

What the third log showed

Run with #40's debug mode (sign tap publishes the request but does not open the wallet):

16:21:54  [tab] visible → connected=true (+609ms)   ← MetaMask approved the pairing and sent the user back
16:21:56  [sign] request on the relay … NOT opening the wallet
16:22:06  [tab] hidden                              ← user switched to MetaMask by hand — no deep link
16:22:14  [tab] visible — "it was hung on splash screen"

MetaMask was already wedged before any deep link was sent to it. Twelve seconds after it approved the pairing and returned the user to the browser, it sat on its splash screen for a plain resume from recent apps. The deep link was never the trigger; every theory built on it — URL shape, gesture, warm resume by intent — is closed.

Whatever puts the wallet in that state happens on the way it returns the user. The one thing here that makes it return the user at all is providerMetadata.redirect (chains.ts, added in #8 — before that, MetaMask left the user in the wallet).

What changes

With debug mode on, initAppKit omits redirect from the metadata handed to the wallet. The wallet leaves the user where they are after approving; they switch back by hand; and when they switch to the wallet again for the signature, the log says whether it is still healthy. Decided inside initAppKit because there are two call sites (LinkPassword's loader and WalletGate) and the first to run wins. AppKit reads the metadata once, so a change of debug mode needs a page reload — the protocol says so.

Also confirmed again by this log: #39's park-on-hidden holds. Three returns from the wallet, all under 400 ms to a live socket.

Testing

npm test --workspaces clean. New appkit.test.ts: redirect present by default, absent with debug mode active, present again when debug mode has expired.

🤖 Generated with Claude Code

https://claude.ai/code/session_013BpqXrkEPA9odTyRdK5Mnx

…back to

The third diagnostic log from the reporter's phone, run with #40's "do not open
the wallet" debug mode:

    16:21:54  [tab] visible -> connected=true (+609ms)   MetaMask approved the pairing, sent the user back
    16:21:56  [sign] request on the relay ... NOT opening the wallet
    16:22:06  [tab] hidden                               user switched to MetaMask by hand -- no deep link
    16:22:14  [tab] visible -- "it was hung on splash screen"

MetaMask was already wedged BEFORE any deep link was sent to it. Twelve seconds
after it approved the pairing and returned the user to the browser, it sat on
its splash screen for a plain resume from recent apps. So the deep link was
never the trigger, and every theory built on it -- URL shape, gesture, warm
resume by intent -- is closed. Whatever puts the wallet in that state happens
on the way it returns the user; the one thing here that makes it return the
user at all is `providerMetadata.redirect` (chains.ts, added in #8 -- before
that, MetaMask left the user in the wallet).

So with debug mode on, `initAppKit` omits the redirect from the metadata it
hands to the wallet. The wallet leaves the user where they are after approving,
they switch back to the browser by hand, and when they switch to the wallet
again for the signature the log says whether it is still healthy. Decided
inside `initAppKit` because there are two call sites (LinkPassword's loader and
WalletGate) and the first to run wins; AppKit reads the metadata once, so a
change of debug mode needs a page reload. Default behaviour is unchanged.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013BpqXrkEPA9odTyRdK5Mnx
@ehsan6sha
ehsan6sha merged commit 7f4e3c7 into main Sep 5, 2026
2 checks passed
@ehsan6sha
ehsan6sha deleted the wallet/debug-no-redirect branch September 5, 2026 16:34
ehsan6sha added a commit that referenced this pull request Sep 5, 2026
…clears a stuck wallet (#42)

Reverts #40 (debug mode: publish the request but do not open the wallet) and
#41 (debug mode: hand the wallet no return address). Both were diagnostics, and
they did their job: four device logs showed MetaMask wedged on its splash screen
on every WARM resume -- by our deep link, by the manual button, by recent apps,
with the redirect on, with it off -- and working on every COLD launch, with or
without a deep link. That isolates the hang to MetaMask's own resume on that
phone. Nothing in the app distinguishes the working case from the failing one.
Left in, the two toggles would give anyone who enables debug mode for support an
altered wallet flow for no further gain.

Untouched, deliberately: the return path. #36/#38's wake and #39's park-on-hidden
are what took the return from the wallet from 8.6 s to under a second, and the
same logs confirm it three times over. `git revert` of exactly the two
experiment commits; relayWake.ts and diag.ts are not in the diff.

The stuck-wallet hint stops blaming Android's battery restriction, which the
same logs ruled out (the wedge appears within seconds of backgrounding; battery
restriction acts over minutes). It now says the thing every log showed working:
close the wallet from recent apps and open it again -- from its icon or with
the button -- and it shows the request.


Claude-Session: https://claude.ai/code/session_013BpqXrkEPA9odTyRdK5Mnx

Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
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