Repository navigation
fix(octane): give each passive-driven commit a fresh nested-update budget - #1688
Conversation
…dget A passive effect that advances state once per commit, next to a layout effect that publishes one converging measurement per commit, threw "Maximum update depth exceeded" around step 50. The synchronous-callback budget was keyed by UPDATE_CHAIN_ID, which passive updates deliberately never bump, and passive effects drained ahead of each re-render merged into it, so no commit ever settled. The budget now has its own chain, reset after any outermost commit with no synchronous-callback update since the previous one (React's commitRootImpl rule). When a block exhausts it while passive effects wait, those effects are held for one render: a passive-driven cascade settles and continues after paint with a dev warning, a real loop schedules again and throws. Layout, ref-callback, store-sync and flushSync-in-useEffect loops still throw. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…hain useLayoutSnapshot's "did not converge" note (#1686) compared its record with block.nestedUpdateChain, which now holds the nested-update chain. Key both on it. A snapshot that converges once per passive step now finishes the cascade instead of throwing with that note. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.
Bugbot Autofix prepared a fix for the issue found in the latest run.
- ✅ Fixed: Deferred layouts can strand held passives
- Added
if (EFFECT_COMMIT_DEPTH === 1) finishNestedUpdateCommit()at the end of completeDeferredLayouts' try block, matching the same outermost-commit closer used by commitEffects, so the held-passive chain is properly released when deferred layout completion acts as the outermost commit boundary.
- Added
Or push these changes by commenting:
@cursor push c6f0d65694
Preview (c6f0d65694)
diff --git a/packages/octane/src/runtime.ts b/packages/octane/src/runtime.ts
--- a/packages/octane/src/runtime.ts
+++ b/packages/octane/src/runtime.ts
@@ -9790,6 +9790,7 @@
const error = drainLayoutUpdates(null);
if (error !== null) throw error.err;
}
+ if (EFFECT_COMMIT_DEPTH === 1) finishNestedUpdateCommit();
} finally {
capture.commits.length = 0;
capture.refs.length = 0;You can send follow-ups to the cloud agent here.
Reviewed by Cursor Bugbot for commit 1e4edfe. Configure here.
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)
9 other measured values are unchanged. Public-import reachability bundles (bytes)
35 other measured values are unchanged. |
completeDeferredLayouts runs deferred layout effects at commit depth 1, where a hold can arm, but commits its follow-up renders at depth 2, where finishNestedUpdateCommit never runs. A probe that settled there left the hold set, and every later passive drain returned early. A passive drain that finds the hold set with no render queued now closes the chain itself: the probe it waited for has already run. While the probe is still queued, the drain keeps holding. Co-Authored-By: Claude Opus 5.5 <[email protected]>
… budget The PR benchmark counts every production function call per operation, and each js-framework operation made 4 more: hasPendingPassiveWork() in commitEffects and drainPassivesBeforeRender, and finishNestedUpdateCommit() on every commit. Restore the inline passive-queue checks and close the sync-callback chain inline; only a settled hold calls out of line. Pin the ordinary per-commit reset with a cascade whose effect advances only after each measurement commits: every step settles without a hold, and removing the reset makes it throw at step 51. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ix (#1689) Raise 72 byte budgets to the bytes #1688 measures plus the usual headroom (32 raw/gzip, 256 brotli). #1688 gives each passive-driven commit a fresh nested-update budget and holds passive effects for one render when a budget runs out. That adds about 250 raw and 100 gzip bytes of scheduler code to every bundle, all inline on the commit path so the PR benchmark's call counters stay flat. Budgets only; no other change. Co-authored-by: Claude Opus 5.5 <[email protected]>
|
The latest updates on your projects. Learn more about Vercel for GitHub. 2 Skipped Deployments
|
#1690 (stacked on #1688) fits every raw and gzip budget that #1689 raised, but measures two brotli values above main's budgets: hydrate-root 48,099 and chat/total 40,951. Raise both to that measurement plus the 256-byte brotli headroom (48,355 and 41,207), so the budgets cover #1688 alone and #1688 + #1690. Budgets only. Co-authored-by: Claude Opus 5.5 <[email protected]>


Summary
A passive effect that advances a step on each commit (
useEffect(() => { if (step < 60) setStep(step + 1) })) threw "Maximum update depth exceeded" around step 50. That happened whenever auseLayoutEffectoruseLayoutSnapshotpublished one converging measurement per commit, even though every measurement converged. On main,useLayoutSnapshotalso blamed itself: "useLayoutSnapshot in … did not converge."Root cause.
block.nestedUpdateCount) was keyed byUPDATE_CHAIN_ID. Passive updates deliberately never bump it, so the passive warning can count the whole cascade.setStepgoes throughcountPassiveUpdate(), but in this case it doesn't. Inside a layout cascade,drainPassivesBeforeRenderruns the passive effect first, and its update merges into the already pending layout re-render.useEffect. Simply resetting on passive updates would therefore never fire here, or would let a real loop spin forever in microtasks.React resets
nestedUpdateCountwhenever a commit leaves no sync work (commitRootImpl), so its passive-driven commits each start fresh.Fix (
runtime.ts):NESTED_UPDATE_CHAIN_ID. It restarts with user, root and unmount updates. It also restarts after any outermost commit that had no sync-callback update since the previous commit. A flag tracks that; an empty-queue check is not enough, because a passive effect's ownflushSyncupdate lands between outermost commits.flushSync-in-useEffectloops strand the hold and loop forever.useLayoutSnapshot's "did not converge" record now keys on the same chain as the budget.completeDeferredLayouts(Bugbot).Validation
pnpm format:check(repo-wide, left to CI)pnpm typecheck(repo-wide, left to CI)pnpm test(full suite, left to CI)octaneandoctane-prod. Each converging cascade (same component,useLayoutSnapshot, child publishing to the parent) throws there.flushSync-in-useEffecttest now also covers two sibling loops.conformance/update-reconciliation,layout-snapshotandlayout-effect-update-prioritypass 86/86 in bothoctaneandoctane-prod.compiler/layout-snapshotpasses 14/14.unstable-selectorsloop still throws.pnpm typecheck:fileson the changed files shows only the fixture file's 39 old implicit-anyerrors.pnpm format:files:check,pnpm changeset:checkandpnpm sync(no generated changes) all pass.cli-spa-startergoes from 115,177 to 115,434 raw (+257) and 38,886 to 38,987 gzip (+101). This PR's own commits change no budget file.Risk / follow-ups
flushSync-in-useEffectloop resets that loop's budget. Unrelated user updates already do this today.flushSyncgap. Passive effects that run ahead of a render inside aflushSyncdrain (syncact(), userflushSync) still count as sync updates. A cascade where no single component measures on every step can still throw there, though not in a normal flush.CURRENT_EFFECT_PHASE === PASSIVE && (!syncFlush || inFlush). It is kept out of this PR because re-pinning the hold guard needs a carefully built fixture. It is tracked as a separate follow-up task.drainPassivePhase, sodrainPassiveEffects()(tier 2) leaves bodies queued while a hold is active, andhasPendingWork()still reports them. The view-transition passive pre-drain falls back to normal scheduling during a hold.Provenance
agent-authored)🤖 Generated with Claude Code
Need help on this PR? Tag
@codesmith-botwith what you need. Autofix is disabled.Note
High Risk
Changes core commit/effect scheduling and nested-update limits in the runtime; incorrect hold or reset logic could affect infinite-loop detection and passive effect timing.
Overview
Aligns Octane’s nested synchronous-update budget with React so passive-driven commits no longer falsely hit “Maximum update depth exceeded” around 50 steps when layout work publishes one converging update per commit (
useLayoutEffect,useLayoutSnapshot, ref callbacks, store sync).The runtime splits passive cascade counting (
UPDATE_CHAIN_ID) from a newNESTED_UPDATE_CHAIN_IDthat tracks per-blocknestedUpdateCount. That chain restarts on user/root updates and after outermost commits that scheduled no sync-callback updates, giving each passive-driven commit a fresh layout budget. When the budget is exhausted while passive effects are still queued, Octane holds those passives for one settling render, then continues with a reset budget and a dev-only warning (not a throw) for long passive cascades; true layout/ref/store/flushSync-in-useEffectloops still error.useLayoutSnapshotdivergence attribution now keys off the same nested chain so converging passive+measure cascades are not labeled “did not converge.”Conformance fixtures and tests cover 60-step passive+measure patterns, passive-only warnings, sibling
flushSyncloops, and layout loops beside passives.Reviewed by Cursor Bugbot for commit fa0f283. Bugbot is set up for automated code reviews on this repo. Configure here.