Repository navigation
fix(octane): keep a recovered arm's streamed payload for a retry - #1759
Merged
Merged
Conversation
When a streamed Suspense arm recovered from an unclosed range, it released the arm's streamed payload right away. If an enclosing Suspense arm or the root then discarded that attempt, the rollback restored the server arm, but the retry hydrated it without its seeds or native manifest. It waited on the client's own requests before finding the damage. The recovery now leaves the payload with the weak marker that owns it. A rollback restores the marker and the retry hydrates from it again. After a commit, the removed marker releases the payload. Co-Authored-By: Claude Opus 5.5 <[email protected]>
trueadm
marked this pull request as ready for review
October 5, 2026 11:27
Contributor
Benchmark report
Compares js-framework: 1k/10k row operationsAll 20 timed operations (20 without a verdict)
All 64 work counters are unchanged. Application bundle size (bytes)
50 other measured values are unchanged. Public-import reachability bundles (bytes)
99 other measured values are unchanged. |
Merged
7 tasks done
This was referenced Oct 5, 2026
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
This addresses the Cursor Bugbot finding on #1753 (review, "Recovery drops streamed seeds early").
When a streamed Suspense arm recovers from an unclosed range, #1753 called
initial.consume?.()right away. If an enclosing attempt was then discarded, the server arm's DOM came back but its payload did not:takeInitialSuspenseHydrationhad already deletedwindow.$OCTS[id]on the first take;consume()deleted the only remaining copy, theinitialStreamedPayloadsentry.The retry therefore hydrated the arm with no seeds and no native manifest. Instead of finding the damaged range, it suspended on the client's own
use()request. Recovery and its #338 report waited for that request to settle.Fix: the unclosed-range recovery no longer releases the payload.
initialStreamedPayloadsis aWeakMapkeyed by the boundary's marker comment, and this path'sremoveRange(getNextSibling(state.start), state.end)removes that marker along with the arm:That is the job the map's own comment gives the weak owner: it "survives discarded nested attempts, but cannot retain a removed boundary." A deferred
consume()modeled on the catch arm also fixed the bug, but it cost +61 raw bytes and broke thehydrate-rootbudget. Dropping the call removes 14 instead.The finding also mentions
initialSuspenseHydrations?.delete(state). That line is shared with the catch path and is unchanged. It is keyed by theTrySlot, and a discarded attempt's retry builds a new slot, which takes the payload again. Both new test cases go through that path.Validation
pnpm format:check: not run repo-wide.pnpm format:files:checkpasses on the three changed files.pnpm typecheck: not run repo-wide.pnpm typecheck:filespasses on the three changed files.pnpm test: left to CI.packages/octane/tests/hydration/unclosed-range.test.ts,--project octane: 31/31, before and after merging main (latest fb404c2).use()data beside a damaged range. After the arm recovers, a later sibling suspends the attempt around it: an outer Suspense arm's attempt in one case, the root's in the other.consume()call restored, all 6 new cases fail at the report assertion (expected [] to deeply equal [StringMatching]). The 25 existing cases pass either way.pnpm sync: no generated changes.Bundle size. Measured with
run-minimal.mjson the merge with main fb404c2.--budgetspasses.hydrate-rootraw / gzipdeferred-hydrationraw / gzipI did not ratchet the budgets down, to leave headroom for the open hydration PRs.
Changeset. None added. The #1753 changeset has not been released yet (it is pending in the Version Packages PR), and its text already describes the behavior this restores.
Risk / follow-ups
useSeedthen marks that thenable fulfilled with the server value before the arm fails over to the client. So with a shared promise object, the client render after recovery reads the server's value; an outer Suspense retry reads the client's. This follows from seeds writing to the thenable they are given, which is how they make later renders synchronous. The test resolves both sides to the same value so it does not depend on this.Provenance
agent-authored)🤖 Generated with Claude Code
Need help on this PR? Tag
@codesmith-botwith what you need. Autofix is disabled.Note
Medium Risk
Touches Suspense/streaming hydration recovery and payload lifetime; behavior change is narrow but in a complex hydration path with nested discard/retry.
Overview
Fixes a hydration bug where unclosed-range recovery on a streamed Suspense arm called
initial.consume()too early, wiping the arm’s streamed seeds before a discarded enclosing attempt could retry.Runtime: In the
UnclosedHydrationRangepath, thatconsume()call is removed. The arm’s payload stays ininitialStreamedPayloadson the boundary marker comment removed byremoveRange, so a rolled-back attempt can restore the marker and rehydrate with server data; a successful commit drops the marker and releases the payload via the weak map.Tests: New streamed fixtures (
StreamedInSuspense,StreamedInRoot) and cases assert that after recovery is undone by a sibling suspend (outer Suspense or root), the retry still reports one recoverable #338 and does not wait on the clientuse()promise to find the damaged range.Reviewed by Cursor Bugbot for commit be729c4. Bugbot is set up for automated code reviews on this repo. Configure here.