Repository navigation
fix(universal): keep live suspense replays across unrelated scheduled renders - #1299
Merged
trueadm merged 1 commit intoSep 24, 2026
Merged
Conversation
… renders A committed @try/@pending boundary wires its thrown thenables into a local replay that re-renders with the pinned memo cache once they settle. The next scheduled render unconditionally deactivated that replay before preparing its own attempt, so when the render only re-executed a scoped owner — or retained the suspended subtree because its inputs looked unchanged — nothing else ever re-attempted the region and pending content stayed on screen after its thenable had already resolved. prepare() now hands a live non-transition replay's memo cache to the fresh attempt and disables retention for it, so the render itself re-attempts the suspended regions: a settled boundary resolves inside that commit, and one still waiting re-suspends and republishes a fresh replay. Transition replays keep their existing supersede semantics.
aleclarson
marked this pull request as ready for review
September 24, 2026 04:03
4 of 6 tasks
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 universal-runtime bug where a scheduled re-render during a suspended
boundary permanently cancels the pending suspense replay, leaving
@pendingcontent on screen forever after the promise resolves.
A committed
@try/@pendingboundary collects its thrown thenables and wiresthem into a
SuspendedMemoReplay: on settle,queueReplay()stores the replayand queues a microtask. But
prepare()unconditionally callscancelSuspendedReplays(true)before preparing its attempt — so when anunrelated scheduled render runs in between (e.g. a
useSyncExternalStorenotification or a sibling
useStatebump), it deactivates the queued replay.runReplay()then early-returns, and when the render only re-executes ascoped owner (
prepareOwnedUpdate) or retains the suspended subtree becauseits inputs look unchanged, nothing else ever re-attempts the region.
prepare()now detects a live non-transition replay for the same componentand hands its memo cache to the fresh attempt (
prepareWithReplaywithallowRetain: false), so the render itself re-attempts the suspended regions:replay (memo entries keep the pinned thenable, so no refetch).
Transition replays keep their existing supersede semantics — they are still
cancelled and their batches requeued so the transition lane re-attempts them.
Validation
pnpm format:checkpnpm typecheck(typecheck:fileson changed files — clean)pnpm testpackages/octane/tests/universal-external-store.test.ts— 2 new regressiontests (settled replay + pending replay across an unrelated store update);
red without the fix, green with it (dev + prod projects)
universal-*test files: 818 tests green in dev + prodpackages/octanesuite: 24,966 pass; 31 failures inbehavior-root,hydration-ssr-diagnostics,compiler/*, andbrowser/*files — none import universal code (verified); timeoutsappear environmental/pre-existing on this base
Not verified on a NativeScript device; fix is at the universal-runtime layer
the NS driver consumes.
Risk / follow-ups
While a replay is live, scheduled renders skip the scoped-owner fast path and
subtree retention for the affected root (a full re-execution, same as
runReplaywould have done). The cost is bounded to the suspension episodeand only when a live replay exists.
Provenance
agent-authored)Need help on this PR? Tag
@codesmith-botwith what you need. Autofix is disabled.Note
Medium Risk
Touches core universal render preparation and Suspense replay lifecycle; wrong handling could affect transitions, retention, or stuck pending UI, but scope is limited to non-transition replays and is covered by new tests.
Overview
Fixes a universal runtime bug where an unrelated scheduled render could cancel a queued Suspense replay and leave
@pendingUI stuck after its promise had already resolved.prepare()now finds an active non-transition replay for the same root component viaabsorbableReplay(), passes its memo cache intoprepareWithReplay, and turns off subtree retention for that attempt so suspended regions are re-executed in the same commit. Settled boundaries can commit their resolved content; still-pending ones re-suspend and publish a new replay. Transition replays are unchanged—they are still cancelled and requeued.While a live replay is present, the scoped-owner shortcut and retain-eligible fast paths are skipped so the retry is not dropped. Two regression tests in
universal-external-store.test.tscover settled and still-pending replays racing an external-store-driven render.Reviewed by Cursor Bugbot for commit 64a32d2. Bugbot is set up for automated code reviews on this repo. Configure here.