Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 25 additions & 1 deletion apps/laboratory/src/components/InitializeBoundary.tsx
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])
Copy link

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 hasTimedOut state is never reset when isInitialized transitions from false to true or back to false. If initialization completes and later resets (e.g., reconnection), the diagnostic message appears immediately instead of after 20 seconds because hasTimedOut remains true from the previous initialization attempt.

Fix in Cursor Fix in Web


// 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()})
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: Startup timestamp misleads by using current time instead of start time

The timestamp displays the current time when the diagnostic message renders, not when initialization actually started. The label says "started:" but new Date().toISOString() creates a fresh timestamp approximately 20 seconds after initialization began, making it misleading for debugging stuck initialization issues.

Fix in Cursor Fix in Web

</div>
)}
</div>
)
}

return children
Expand Down
Loading