Fix onboarding private-domain history.replaceState loop past Safari's rate limit - #97709
Draft
MelvinBot wants to merge 1 commit into
Draft
Fix onboarding private-domain history.replaceState loop past Safari's rate limit#97709MelvinBot wants to merge 1 commit into
MelvinBot wants to merge 1 commit into
Conversation
…ate limit Co-authored-by: Joe Ph <gijoe0295@users.noreply.github.com>
Contributor
Author
|
The failing check is unrelated to this PR — it's a pre-existing flaky UI test. No code change is needed here. Failing checks breakdown:
Why it's flaky, not caused by this PR
Per policy I don't fix unrelated/flaky failures — re-running |
Contributor
Author
|
No code fix is warranted — the failure is a pre-existing flaky test unrelated to this PR. The fix is to re-run the failed job. The head commit is unchanged (
Action: re-run the failed job — Re-run failed jobs on run 30835265733. It should go green. I don't push code changes for unrelated/flaky failures per policy. Why it's a flake, not a regression from this PR
|
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.
Explanation of Change
On
/onboarding/private-domain, two redirectors disagreed about where a validated private-domain user belongs, so they bounced that user back and forth. Each bounce is onehistory.replaceState; Mobile Safari caps that at 100/10s and throwsSecurityError: Attempt to use history.replaceState() more than 100 times per 10 seconds. The rate limit is the symptom — the bug is the loop.BaseOnboardingPrivateDomainredirects validated users off this screen (to Workspaces if there are joinable policies, else Purpose/Employees) viaforceReplace.getOnboardingInitialPathonly redirected public-domain validated users away from private-domain; validated private-domain users with accessible policies fell through and got the staleinitialPath(/onboarding/private-domain) returned, souseOnboardingFlowRouterreset them right back onto the screen.Screen says "leave", router said "stay" → ping-pong →
replaceStatespam → SafariSecurityError.This PR makes the two agree:
OnboardingFlow.ts: when the last-visited path is/onboarding/private-domainand the account is validated, the router now resolves forward — Workspaces when there are accessible policies (mirroring the screen), otherwise Purpose/Employees — instead of returning the stale private-domain path. The existing guard only covered public-domain validated users; it now also covers validated private-domain users. Unvalidated users still stay on the screen to confirm their code.BaseOnboardingPrivateDomain.tsx: auseRef"hasRedirected" guard so the forced-replace redirect fires at most once per mount, boundingreplaceStatecalls even if a re-mount slips through.Unit tests were added to
tests/unit/OnboardingFlowTest.tscovering the new router branches (validated private-domain → Workspaces / Purpose / Employees, and unvalidated private-domain staying put).Fixed Issues
$ #97473
PROPOSAL: #97473 (comment)
Tests
// TODO: The human co-author must fill out the manual tests they ran before marking this PR as "ready for review".
// Suggested flow: sign up with a private email domain, proceed onboarding to
/onboarding/private-domain, validate the account, and confirm the app redirects forward cleanly (to the join-workspace / purpose step) without the URL flapping between routes and with noSecurityError/history.replaceStateerrors in the console.// Note: automated unit tests for the router logic were added in
tests/unit/OnboardingFlowTest.tsand pass.Offline tests
QA Steps
// TODO: The human co-author must fill out the QA steps before marking this PR as "ready for review", or the issue title must include "[No QA]."
PR Author Checklist
### Fixed Issuessection aboveTestssectionOffline stepssectionQA stepssectionAvatar, I verified the components usingAvatarare working as expected)StyleUtils.getBackgroundAndBorderStyle(theme.componentBG))npm run compress-svg)Avataris modified, I verified thatAvataris working as expected in all cases)Designlabel and/or tagged@Expensify/designso the design team can review the changes.mainbranch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTeststeps.Screenshots/Videos
Android: Native
Android: mWeb Chrome
iOS: Native
iOS: mWeb Safari
MacOS: Chrome / Safari