test: failing test for hydration race when a subscriber exists before RouterProvider mounts - #15308
Open
marlass wants to merge 2 commits into
Open
test: failing test for hydration race when a subscriber exists before RouterProvider mounts#15308marlass wants to merge 2 commits into
marlass wants to merge 2 commits into
Conversation
… RouterProvider mounts
Same scenario as the existing race-condition regression test, plus a
single router.subscribe(() => {}) call before RouterProvider mounts,
which is what Sentry's wrapCreateBrowserRouterV7 instrumentation does at
router creation. Because bufferedInitialStateUpdate is only armed when
updateState runs with zero subscribers, RouterProvider's layout-effect
subscription gets no replay and the app renders the HydrateFallback
forever.
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.
Same scenario as the existing race-condition regression test, plus a single router.subscribe(() => {}) call before RouterProvider mounts, which is what Sentry's wrapCreateBrowserRouterV7 instrumentation does at router creation. Because bufferedInitialStateUpdate is only armed when updateState runs with zero subscribers, RouterProvider's layout-effect subscription gets no replay and the app renders the HydrateFallback forever.
The bug from #14356 is back in 7.16.0+ and 8.x, with one extra condition: a subscriber attached to the router before RouterProvider mounts. The most common real-world source is Sentry — wrapCreateBrowserRouterV7 calls router.subscribe(...) at router creation. Combined with anything suspending above RouterProvider (code-split shell, i18n bundle), fast loaders / cached route.lazy chunks resolve before RouterProvider's subscribe() layout effect runs, the initialization update is lost, and the app renders the HydrateFallback forever. Fast responses fail, slow ones work, so it presents as an intermittent hang that is worst on warm caches.