Fix typespec-java emitter build hanging parallel pnpm build - #5004
Merged
Conversation
…SIGTTOU) The Java emitter build intermittently hung a full `pnpm build`, stopping right after "using current checkout" and never printing "Copy generator sources from core". Root cause: turbo runs each task in its own background process group under the build's controlling terminal. When a PowerShell cmdlet renders Write-Progress (notably `Copy-Item -Recurse` in Copy-Sources.ps1), pwsh touches that terminal from a background process group and the OS stops the process with SIGTTIN/SIGTTOU -- it never resumes, so the build hangs forever. It only affects typespec-java (the sole package that shells out to pwsh) and is intermittent (progress only renders when the copy is slow enough under load), which is why it survived earlier fix attempts and is invisible when output is piped. Fix: set `$ProgressPreference = 'SilentlyContinue'` in the .ps1 build scripts so no cmdlet touches the terminal. Also harden the pinned-core read: only `git fetch` when the commit is missing locally, and make git/pwsh non-interactive (GIT_TERMINAL_PROMPT=0, `pwsh -NonInteractive`) so a prompt can never block the headless build. Extract archives with ZipFile.ExtractToDirectory instead of the slow Expand-Archive.
Contributor
|
All changed packages have been documented.
Show changes
|
commit: |
timotheeguerin
marked this pull request as ready for review
July 21, 2026 22:22
timotheeguerin
requested review from
XiaofeiCao,
alzimmermsft,
bterlson,
haolingdong-msft,
markcowl and
weidongxu-microsoft
as code owners
July 21, 2026 22:22
Contributor
|
You can try these changes here
|
weidongxu-microsoft
approved these changes
Jul 22, 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.
Problem
A full-repo
pnpm buildintermittently hangs at the Java emitter build. The output stops right after:and never reaches
Copy generator sources from core. Buildingpackages/typespec-javaon its own always works. Prior attempts (#4972, #4983, and non-interactive/fetch hardening) did not resolve it.Root cause
turbo runs each task's process in its own background process group under the build's controlling terminal (the TUI). When a PowerShell cmdlet renders
Write-Progress— whichCopy-Item -RecurseinCopy-Sources.ps1does — pwsh touches that terminal from a background process group and the OS stops the process with SIGTTIN/SIGTTOU (Tstate). It never resumes, so the build hangs forever.This explains all the symptoms:
pwsh.Copy-Itemonly renders progress when the copy is slow enough (under parallel-build load).-NonInteractive: progress renders regardless.Reproduced directly: a pwsh running
Write-Progressin a background process group under a controlling tty immediately entersT(stopped); with$ProgressPreference = 'SilentlyContinue'it never stops.Fix
$ProgressPreference = 'SilentlyContinue'inCopy-Sources.ps1,Build-Generator.ps1, andCoreCommit.ps1so no cmdlet touches the controlling terminal. This is the actual fix.Complementary hardening (removes secondary hang/network vectors):
CoreCommit.ps1: onlygit fetchthe pinned core commit when it is genuinely missing locally (git cat-file -e <sha>^{commit}first) — previously it hit the network on every emitter build / doc regen.CoreCommit.ps1:GIT_TERMINAL_PROMPT=0andpwsh -NonInteractive(package.json) so a git credential/host prompt can never block the headless build.CoreCommit.ps1: extract pinned sources with[System.IO.Compression.ZipFile]::ExtractToDirectoryinstead of the pathologically slowExpand-Archive.Verification
T-state stop withWrite-Progressunder a controlling tty; confirmed$ProgressPreference='SilentlyContinue'prevents it.Copy-Sources.ps1in a background process group under a controlling tty never stop.pnpm buildcompletes 63/63;git -C core statusstays clean.