Repository navigation
test(launcher): WaitForPidAsync names its role, bound and stderr on timeout - #889
Merged
Merged
Conversation
…imeout When its hang guard fires, LadderTree.WaitForPidAsync now throws a TimeoutException instead of a bare TaskCanceledException: "The ladder tree reported no '<role>' pid within <seconds> s: <stderr lines joined with ' | '>", seconds in invariant culture, stderr read fresh in the catch, the caught cancellation as the inner exception. The catch wraps only the pause and filters on the guard's own token. The guard and the pause run on an injected TimeProvider through a new overload; the three-argument method the nine callers use chains to it with TimeProvider.System, so their success path is unchanged. LadderTreeTests runs both cases on ManualTimeProvider: the named timeout (with a stderr line appended after the wait starts and the wait asserted incomplete before the clock moves) and a pid that arrives during the wait. real-clock.txt: LadderTree.cs drops from 2 sites to 1. The guard no longer sees new CancellationTokenSource(hangGuard); it still counts the NET arm's Task.Delay(..., time, ...). Refs #787
This was referenced Nov 17, 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.
Refs #787
The #789 review found that
LadderTree.WaitForPidAsync(tests/OpenCode.Sdk.Tests/Hosting/Launcher/Support/LadderTree.cs) surfaced a bareTaskCanceledExceptionnaming no role and no stderr when its hang guard fired, while the non-waitingLadderTree.Pidnames both. This PR fixes that finding and leaves the issue open: it stays open for its 14-day quiet window from the 2026-11-05 sighting, and the coordinator ends it by hand on 2026-11-19 if no new sighting appears.Change
TimeoutException:The ladder tree reported no '<role>' pid within <seconds> s: <stderr lines joined with " | ">. Seconds use the invariant culture, asServerStartupTreeHandshake.HandshakeStep.Timeoutformats its bound; stderr is a fresh snapshot read in the catch; the caught cancellation is the inner exception. The catch wraps only the pause and filters on the guard's own token.TimeProviderthrough a new overload, so the timeout can be tested onManualTimeProvider(testing-style.md: "The event decides a verdict, never the clock"). The three-argument method the nine callers use chains to it withTimeProvider.System; their success path is unchanged (read before pause, freshPids(output)each turn, 10 ms pause). The#if NETsplit for the delay follows the six existingsrcsites.tests/OpenCode.Sdk.Tools.Tests/RepositoryGates/real-clock.txt:LadderTree.csdrops from 2 real-clock sites to 1 (the guard no longer seesnew CancellationTokenSource(hangGuard); it still counts the NET arm'sTask.Delay(..., time, ...)).Tests:
Support/LadderTreeTests.cs(new, mirror rule)WaitForPidAsync_Should_Name_The_Role_Bound_And_Stderr_When_The_Guard_Fires: one stderr line before the wait and one after it starts; the wait is asserted incomplete once the guard is armed and before the clock moves; then the exact message and an inner cancelledOperationCanceledException.WaitForPidAsync_Should_Return_The_Pid_That_Arrives_During_The_Wait: the pid line arrives after the pause is armed; the exact pid comes back.Red proof (worker, with analyzers): with only the catch removed, test 1 fails at
Throws<TimeoutException>because aTaskCanceledExceptionarrives, on net472, net10.0 and net11.0; test 2 passes either way.Verification
b6f704fb, under the machine's gate lock: slopwatch, Release build, both format passes, clone gate,OpenCode.Sdk.Tools.Tests, and the wholeOpenCode.Sdk.Testsfilter ((Category!=ServiceElection)&(Category!=NativeAot)): 12,631/12,631.94a9f4c2(squash and one doc-comment change): static steps, Tools tests 2,792/2,792, andLadderTreeTests2/2 on each of net472, net10.0 and net11.0.ManualTimeProvider, added the mid-wait cases); Opus review of the diff (no blocker or major; two minors fixed).