Fix crash on load when no wallet extension is installed#3
Open
drhus wants to merge 1 commit into
Open
Conversation
InstallSnap read window.ethereum.networkVersion unguarded; on any browser without MetaMask (all mobile) this threw and took down the whole page with "Application error: a client-side exception has occurred". NavBar renders InstallSnap on every page, so the site was unusable without a wallet. Guard the accesses with optional chaining - without a wallet the OR Snap button now renders disabled instead of crashing. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Contributor
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
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.
Problem
or.immo shows "Application error: a client-side exception has occurred" for any visitor without a browser wallet - which includes every mobile browser. Console:
NavBarrenders<InstallSnap displayManualInstall={true}/>on every page, andInstallSnapreadswindow.ethereum.networkVersionwithout checking that a wallet is injected. No MetaMask →window.ethereumisundefined→ React unmounts the whole page.Fix
Optional-chain the three unguarded
window.ethereumaccesses (InstallSnap.tsx,snap.ts). With no wallet the page now renders fully; the OR Snap button remains visible and clicking it is a harmless no-op (win.ethereum?.requestshort-circuits). Note: Chakra'sButtondoes not apply the plaindisabledprop to the DOM (pre-existing - it wantsisDisabled), so the button is not greyed out; left as-is to keep this fix minimal. Behavior with MetaMask is unchanged.Verification
next dev) in headless Chrome with no wallet: full homepage renders, zero exceptions (screenshot-verified).next build: compile + type check pass. (Page-data collection fails locally on Node 22 with a pre-existingimport ... assertissue in/dashboard; Vercel builds on Node 20.x where it works.)🤖 Generated with Claude Code