Skip to content

Pre-warm the 3 most recently used bundles on server start - #2218

Closed
vzaidman wants to merge 2 commits into
react:mainfrom
vzaidman:metro-prewarm-recent-bundles
Closed

vzaidman wants to merge 2 commits into
react:mainfrom
vzaidman:metro-prewarm-recent-bundles

Conversation

@vzaidman

Copy link
Copy Markdown
Contributor

Summary

Pre-build the 3 most recently used bundles when Metro starts serving, most recent first, so the first request after a restart is served from a warm build.

  • A request for a bundle being pre-built joins that build instead of starting a second one.
  • Any bundle request cancels the remaining pre-warm queue; an in-flight pre-build keeps going and serves the request.
  • Recency is recorded only for successfully served bundle requests and persists across restarts.

Changelog: [Performance] Pre-warm the 3 most recently used bundles on server start

Test plan

Added packages/metro/src/Server/__tests__/Server-prewarm-test.js, covering: pre-building the 3 most recent bundles on start, sharing an in-flight pre-build with a concurrent request, cancelling queued pre-warms on a bundle request, taking over a queued pre-warmed bundle, surviving a failed pre-warm build, and persisting recency across restarts with only successful requests updating it.

$ yarn jest packages/metro/src/Server
Test Suites: 4 passed, 4 total
Tests:       111 passed, 111 total

Pre-build the 3 most recently used bundles when Metro starts serving, most recent first. A request for a bundle being pre-built joins that build instead of starting a second one, and any bundle request cancels the remaining pre-warm queue while an in-flight pre-build keeps going and serves the request. Recency is recorded only for successfully served bundle requests and persists across restarts.
Cover pre-building the 3 most recently used bundles on start, sharing an in-flight pre-build with a concurrent request, cancelling queued pre-warms on a bundle request, taking over a queued pre-warmed bundle, surviving a failed pre-warm build, and keeping recency across restarts with only successful requests updating it.
@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Nov 11, 2026
@vzaidman vzaidman closed this Nov 11, 2026
@vzaidman
vzaidman deleted the metro-prewarm-recent-bundles branch November 11, 2026 15:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant