-
Notifications
You must be signed in to change notification settings - Fork 1.6k
fix(laboratory): improve initialization timeout handling #5250
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
04f9af6
bba0c72
9274e63
5990448
c256203
68ced57
e6d140f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,11 +1,35 @@ | ||
| import { useEffect, useState } from 'react' | ||
|
|
||
| import { useAppKitState } from '@reown/appkit/react' | ||
|
|
||
| export default function InitializeBoundary({ children }: { children: React.ReactNode }) { | ||
| const { initialized: isInitialized } = useAppKitState() | ||
| const [hasTimedOut, setHasTimedOut] = useState(false) | ||
|
|
||
| useEffect(() => { | ||
| if (!isInitialized) { | ||
| const timeout = setTimeout(() => { | ||
| setHasTimedOut(true) | ||
| }, 20_000) | ||
|
|
||
| return () => clearTimeout(timeout) | ||
| } | ||
|
|
||
| return undefined | ||
| }, [isInitialized]) | ||
|
|
||
| // Add a loading skeleton | ||
| if (!isInitialized) { | ||
| return <div data-testid="w3m-page-loading">Initializing...</div> | ||
| return ( | ||
| <div data-testid="w3m-page-loading"> | ||
| Initializing... | ||
| {hasTimedOut && ( | ||
| <div style={{ marginTop: '10px', fontSize: '12px', color: '#888' }}> | ||
| Still initializing after 20s (started: {new Date().toISOString()}) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Bug: Startup timestamp misleads by using current time instead of start timeThe timestamp displays the current time when the diagnostic message renders, not when initialization actually started. The label says "started:" but |
||
| </div> | ||
| )} | ||
| </div> | ||
| ) | ||
| } | ||
|
|
||
| return children | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bug: Timeout flag leaks across reinitializations
The
hasTimedOutstate is never reset whenisInitializedtransitions fromfalsetotrueor back tofalse. If initialization completes and later resets (e.g., reconnection), the diagnostic message appears immediately instead of after 20 seconds becausehasTimedOutremainstruefrom the previous initialization attempt.