Repository navigation
perf: preload eligible lazy modules safely - #703
Merged
domgan-oai merged 1 commit intoAug 10, 2026
Merged
domgan-oai merged 1 commit into
domgan-oai merged 1 commit into
Conversation
domgan-oai
marked this pull request as ready for review
August 10, 2026 23:15
95 tasks done
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
lazy()module loader during an existing suspended sibling's compiler-proven warm plan instead of waiting for all data dependencies to resolve.<Hydrate>boundaries opaque to speculative discovery; only their own activation or explicitly configured prefetch may load deferred code.Correctness and scope
warmChildreachability/guard proof; no compiler, server-runtime, public API, or hydration-chunk extraction changes.lazy()payload initializer between speculative module discovery and actual rendering; do not execute component code, hooks, DOM, effects, or resolved module export accessors during discovery.Production browser evidence
The existing async-composition dashboard gains one real, separately code-split synchronous lazy child. The browser benchmark adds a deterministic 35 ms delay to that actual JavaScript chunk and compares unchanged canonical runtime versus candidate runtime on the same authored dashboard, minification policy, Chromium environment, and interleaved AB/BA samples.
The eligible lazy module becomes visible approximately 40.4 ms sooner (27.6%) because its delayed code request overlaps the existing first data wave. The data-only dashboard-ready and update timings are unchanged within measurement noise; this does not claim faster data fetching. The separate module chunk remains 324 bytes; the affected main application adds 237 raw bytes / 80 gzip bytes. The fixed 16-file compiler-output corpus and all unrelated generic production bundles are byte-identical.
Validation
never()island remains untouched while an outside sibling actually warms, then explicitly activates once and adopts its original server DOM.8/8/7/2/0data, wave, and atomicity controls.lazy()elimination, and fixed compiler-corpus byte comparisons.pnpm --config.verify-deps-before-run=false --config.enable-pre-post-scripts=false run typecheck.pnpm --config.verify-deps-before-run=false sync.git diff --check.Refs #673.
Provenance
agent-authored)Note
Medium Risk
Touches core
lazy()and Suspense warm-path semantics (loader timing, once-only loads, sync-thenable errors, Hydrate opacity); behavior is heavily tested but mistakes could cause duplicate loads or premature chunk fetches.Overview
Eligible
lazy()loaders can start while an independently suspended sibling is already in a compiler-proven warm plan, overlapping dynamic-import fetches with pending data instead of waiting for the boundary to reach the lazy child.The runtime refactors
lazy()soinitializeLazyis shared between first render and speculative warming vialazyWrapper.__warm. Loaders still run once; resolved modules and default-export getters are not read until the component actually renders. Dormant<Hydrate>islands, unselected@ifbranches, and code behindnever()stay out of discovery until activation or explicit prefetch.Error handling adds
fulfilled-error/rejected-errorso a thenable that settles synchronously and then throws during.thenregistration replays that failure on the first real render instead of leaking a cached payload after speculative warm.Validation extends
lazy.test.ts(parallel siblings, concurrent roots, Hydrate dormancy, conditionals, rejections, sync loader/subscription failures), adds a code-splitLazyCodeProofto the async-composition Octane dashboard, and tightens the Chromium gate (35ms chunk delay, single loader/request, overlap with the firstprojectwave, stable DOM across transition). Docs describe the React difference and that lazy discovery does not enter dormant Hydrate boundaries.Reviewed by Cursor Bugbot for commit b16a866. Bugbot is set up for automated code reviews on this repo. Configure here.