fix(web): reload the preview iframe through about:blank on retry - #5328
Open
pedrofrxncx wants to merge 1 commit into
Open
fix(web): reload the preview iframe through about:blank on retry#5328pedrofrxncx wants to merge 1 commit into
pedrofrxncx wants to merge 1 commit into
Conversation
The just-merged self-heal watchdog (#5324) retries a stuck iframe by reassigning `iframe.src` to the same URL string it already has. In several browsers (e.g. Firefox) reassigning an unchanged `src` is a silent no-op — the exact failure mode this watchdog exists to recover from, since the frame never left that URL. Bounce through `about:blank` first so the retry always triggers a real navigation.
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.
Follows #5324 (self-heal preview iframe stuck on connection-refused), merged to main just before this run.
The bug
useIframeLoadRecovery's retry path (preview-iframe-recovery.ts) reassigns the iframe'ssrcto the exact same URL string it already has to force a reload:But in the failure case this watchdog exists to recover from, the iframe never navigated away from that URL in the first place (it's stuck on the browser's connection-refused page while
srcstill reads the sandbox URL). Reassigning an unchangedsrcstring is a documented no-op in several browsers (Firefox in particular skips the navigation entirely when the value doesn't change; this is the well-known "iframe src reload hack is unreliable" gotcha). So the entire self-heal mechanism silently does nothing in those browsers — it schedules retries forever but the frame never actually reloads.The fix
Bounce through
about:blankbefore restoring the target URL, so the assignment always differs from the previous value and reliably triggers a real navigation:Regression test
Added
preview-iframe-recovery.test.ts, which fakessetTimeout/clearTimeoutwith a manually-flushed queue (the real watchdog/backoff delays are 10s/1s) and asserts the iframe'ssrcassignment sequence on retry. Confirmed it fails against the pre-fix code (git stash+ rerun) with the exact same-string no-op it's meant to catch, and passes with the fix.To verify
Checks run locally
bun run fmtbunx tsc --noEmitinapps/webFull CI validates the rest.
Summary by cubic
Fixes the preview iframe self-heal so retries trigger a real reload by bouncing through about:blank. Prevents endless retries on browsers that treat same-URL
srcassignments as no-ops (e.g., Firefox).useIframeLoadRecoveryto setiframe.src = "about:blank"before restoring the target URL.about:blank → targetsequence with fake timers.Written for commit a4e7ca1. Summary will update on new commits.