fix(experiment-tag): keep anti-flicker overlay up during redirect navigation#337
Open
tyiuhc wants to merge 1 commit into
Open
fix(experiment-tag): keep anti-flicker overlay up during redirect navigation#337tyiuhc wants to merge 1 commit into
tyiuhc wants to merge 1 commit into
Conversation
…igation Cross-subdomain redirect impression tracking made the redirect path async (handleRedirect awaits setMarketingCookie, which resolves the registrable domain). location.replace() queues navigation but JS keeps running and the browser keeps painting the source page until the destination commits. The anti-flicker teardown (removeAntiFlickerCss) then ran inside that window and stripped the overlay — including a customer's #amp-exp-css snippet — flashing the source page mid-redirect. Gate every anti-flicker teardown path on a new isRedirecting flag: - experiment.ts: set isRedirecting before location.replace(); skip removeAntiFlickerCss() and further remote processing in start() while a redirect is in-flight. Replaces an earlier never-resolving-promise stall. - index.ts: the bootstrap .finally() and the preview/extension path now skip removeAntiFlickerCss() when client.isRedirecting (preview path returns the startClient promise so teardown flows through the single gated finally). Isolated from the cross-subdomain redirect feature branch. Refs Questrade. Co-authored-by: Cursor <cursoragent@cursor.com>
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.
Summary
Fixes a redirect "flash" in cross-subdomain redirect experiments.
#238 (cross-subdomain redirect impression tracking) made the redirect path async:
applyVariants/handleRedirectbecame async andhandleRedirectnowawaitssetMarketingCookie, which resolves the registrable domain.location.replace()only queues navigation — JS keeps running and the browser keeps painting the source page until the destination commits. The anti-flicker teardown (removeAntiFlickerCss) ran inside that window and stripped the overlay (including a customer's#amp-exp-csssnippet), flashing the original page mid-redirect.The previously released version was not affected because its redirect path was synchronous (fire-and-forget cookie write, no
awaitbeforelocation.replace()), so there was no gap for the overlay to be torn down. The flash is specific to the async redirect path introduced in #238.Changes
Gate every anti-flicker teardown path on a new
isRedirectingflag:experiment.ts— setisRedirecting = truebeforelocation.replace(); skipremoveAntiFlickerCss()and further remote processing instart()while a redirect is in-flight.index.ts— the bootstrap.finally()and the preview/extension path skipremoveAntiFlickerCss()whenclient.isRedirecting. The preview path returns thestartClientpromise so teardown flows through the singleisRedirecting-gatedfinally.Test plan
experiment.test.tsgreen (36 tests); assertsisRedirectingis set on the redirect path so the bootstrap skips teardown.Notes