Skip to content

Preserve build diagnostics during worker shutdown - #101598

Merged
unstubbable merged 1 commit into
canaryfrom
hl/fix-build-worker-output
Nov 12, 2026
Merged

unstubbable merged 1 commit into
canaryfrom
hl/fix-build-worker-output

Conversation

@unstubbable

Copy link
Copy Markdown
Contributor

PR #97900 fixed output capture between the build CLI and the test harness. The CLI could still exit before it forwarded the static workers' final diagnostics, so debug prerenders intermittently failed without the expected sync IO error.

The build now awaits static worker shutdown, and Worker.end() waits for stdout and stderr to finish. Neither stream ends the shared activity sink while the other can still produce output.

This re-enables the sync-io-blocks-root test suite, whose earlier re-enablement was reverted in PR #98050.

PR #97900 fixed output capture between the build CLI and the test
harness. The CLI could still exit before it forwarded the static
workers' final diagnostics, so debug prerenders intermittently failed
without the expected sync IO error.

The build now awaits static worker shutdown, and `Worker.end()` waits
for stdout and stderr to finish. Neither stream ends the shared activity
sink while the other can still produce output.

This re-enables `sync-io-blocks-root`, whose earlier re-enablement was
reverted in PR #98050.
@github-actions

github-actions Bot commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

Tests Passed

Commit: 256c205
View workflow run

@unstubbable
unstubbable marked this pull request as ready for review November 11, 2026 22:10
@unstubbable
unstubbable requested review from sokra and a balanced review from Copilot and removed request for Copilot November 11, 2026 22:10
@unstubbable
unstubbable merged commit 1430e15 into canary Nov 12, 2026
126 of 127 checks passed
@unstubbable
unstubbable deleted the hl/fix-build-worker-output branch November 12, 2026 09:23
sokra added a commit that referenced this pull request Nov 12, 2026
Replace the vendored jest-worker with a purpose-built pool in
lib/worker/: lazy spawning, boot throttling, per-worker concurrency,
crash recovery and graceful shutdown, for both child processes and
worker threads. Build, export, type-check, the dev server, the
dev-validation worker and the 'use cache' probe pool use it.

Workers exit with process.exit() after teardown on END, so leftover
ref'd handles can't hold up graceful shutdown until the force-kill
timeout ('exit' handlers such as CPU profile saving still run). Child
processes first flush their stdout/stderr pipes so final diagnostics
aren't cut off. Graceful shutdown also waits, bounded by the force-exit
delay, for each worker's output streams to end, and the Worker wrapper
resolves only once that output reached the parent's stdout/stderr
(ports #101598 to the new pool). The export worker now clears its
per-page staticPageGenerationTimeout timer once the export settles.
While CPU profiling, graceful shutdown waits up to 60 s before
force-killing a worker so large profiles aren't cut off.

Prerender early exit now throws back to the build instead of exiting
inside the worker; the CLI prints the message unchanged and deferred
Turbopack warnings still follow it. Calls whose arguments fail to
serialize, and workers whose module fails to load, reject their calls
with the real error instead of wedging or crashing the pool. Leftover
jest-worker references are removed and the Turbopack server NFT prunes
the worker child entrypoints outside standalone builds.

Co-authored-by: Tobias Koppers <1365881+sokra@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants