wallet: in debug mode, do not tell the wallet where to send the user back to - #41
Merged
Conversation
…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
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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):
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,
initAppKitomitsredirectfrom 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 insideinitAppKitbecause there are two call sites (LinkPassword's loader andWalletGate) 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 --workspacesclean. Newappkit.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