-
Notifications
You must be signed in to change notification settings - Fork 0
fix: resolve Velt auth timing issue in master-sample-app iframes #37
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
Conversation
On first load, demo iframes would get stuck because Velt SDK tried to connect before authentication completed (~8s). This fix waits for auth to complete, then refreshes the iframes. Subsequent visits skip the delay by checking a localStorage flag per demo origin. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <[email protected]>
🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <[email protected]>
| // Force refresh by resetting src | ||
| iframe1Ref.current.src = url | ||
| } | ||
| }, VELT_AUTH_WAIT_MS) |
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.
Stale URL closure in timer causes wrong document
When the url prop changes (e.g., user clicks reset during the first 8-second wait), handleIframeLoad sets a new timer but doesn't cancel the existing one. The old timer's closure still captures the previous url value. When the old timer fires, it sets iframe.src to the stale URL, causing the iframe to briefly show the wrong document. The clearTimeout calls only exist in the unmount cleanup effect, not before setting new timers in handleIframeLoad.
On first load, demo iframes would get stuck because Velt SDK tried to connect before authentication completed (~8s). This fix waits for auth to complete, then refreshes the iframes. Subsequent visits skip the delay by checking a localStorage flag per demo origin.
🤖 Generated with Claude Code
Pull Request
Description
Type of Change
Monorepo Structure Checklist
If adding a new demo, ensure you've followed the 5-level structure:
apps/<framework>/<document>/<type>/<implementation>/<library-or-solution>/<demo>/package.jsonwith scoped name:@apps/<framework>-<document>-<library-or-solution>-<demo>pnpm --filter <package-name> buildpnpm --filter <package-name> devDeployment Checklist
If this demo should be deployed:
Testing
pnpm -w install && pnpm -w buildDocumentation
master-sample-app(if applicable)Related Issues
Screenshots/Videos
Additional Context
For Reviewers
Demo Location
Path:
apps/<framework>/<document>/<type>/<implementation>/<library-or-solution>/<demo>/Package name:
@apps/<...>How to Test
Structure Verification
The demo follows the 5-level hierarchy:
Documentation: See README_MONOREPO.md and docs/structure.md for more details on the monorepo structure.
Note
Addresses demo iframe stalls caused by Velt SDK auth timing.
IframePairwaits ~8s for Velt auth, then refreshes iframes once; marks origins as initialized vialocalStorage(velt-initialized-<origin>) to skip future delays. Adds refs/timers with unmount cleanup and shows an "Initializing" overlay until refresh completes.SampleViewerkeys iframes only bysample.metadata.id(notdocumentId) to prevent remounts while document IDs change; continues to appenddocumentIdto iframe URLs and gates rendering until ready.page.tsxand viewer components.Written by Cursor Bugbot for commit 20163cf. This will update automatically on new commits. Configure here.