[test] Fix flaky build CLI output capture - #97900
Merged
Merged
Conversation
Co-authored-by: Tobias Koppers <1365881+sokra@users.noreply.github.com>
Contributor
Stats from current PR🟢 1 improvement
📊 All Metrics📖 Metrics GlossaryDev Server Metrics:
Build Metrics:
Change Thresholds:
⚡ Dev Server
📦 Dev Server (Webpack) (Legacy)📦 Dev Server (Webpack)
⚡ Production Builds
📦 Production Builds (Webpack) (Legacy)📦 Production Builds (Webpack)
📦 Bundle SizesBundle Sizes⚡ TurbopackClient Main Bundles
Server Middleware
Build DetailsBuild Manifests
Build Cache
📦 WebpackClient Main Bundles
Polyfills
Pages
Server Edge SSR
Middleware
Build DetailsBuild Manifests
Build Cache
🔄 Shared (bundler-independent)Runtimes
📎 Tarball URLCommit: 5df331c |
Contributor
Tests PassedCommit: 5df331c |
sokra
marked this pull request as ready for review
August 25, 2026 22:00
eps1lon
approved these changes
Aug 26, 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.
What?
Stabilize
NextStartInstance.build()CLI output capture so failed production builds return all trailing stdout/stderr diagnostics.The existing
sync-io-blocks-rootbehavioral assertions remain unchanged, including the route-specificDate.now()diagnostic, timeout/retry guard, and exit-code check.Why?
The
--debug-prerendercases intermittently lost the detailedDate.now()diagnostic fromresult.cliOutputin CI even though builds exited normally. Across the reported CI run and two retries, the missing route set varied from 4 to 2 to 3 routes, consistent with an output-drain race rather than a rendering or resource failure.On latest canary with Node 20,
NEXT_TEST_MODE=start, andIS_WEBPACK_TEST=1, 5 baseline campaigns completed 24 builds (20 debug-prerender) without reproducing the intermittent failure locally. A controlled Node 20 reproduction established the lifecycle race directly: the childexitevent observed no trailing output, whilecloseobserved the trailing diagnostic.How?
Wait for the child process
closeevent before snapshottingcliOutput. Unlikeexit,closeis emitted after the piped stdout and stderr streams close, so diagnostics emitted near process shutdown are fully drained before the build result is returned.This is intentionally limited to the affected start-mode build harness and is independent of the mmap persistence PR stack (#97873, #97888, #97889).
Verification
exitcaptured empty output;closecaptured the trailing diagnosticpnpm build-alltest/lib/next-modes/next-start.tspnpm types