Repository navigation
Fix product process-output hang and process-wrapper leaks - #70076
Conversation
There was a problem hiding this comment.
🔵 Needs a closer look
Cross-platform process-lifetime changes, especially IIS Express parent-exit cleanup and Unix monitoring, lack final-revision runtime validation and require human verification on supported operating systems.
No open issues 🎉
What changed in this PR
Modernizes process management across ASP.NET Core tooling, shared infrastructure, and tests using .NET 11 APIs. It also provides practical feedback for the process-api-net11 skill without changing shipping public APIs.
Changes:
- Replaces eligible output-capture and exit-waiting code with built-in process APIs while retaining live logging and readiness handling.
- Updates timeout, cancellation, process cleanup, signaling, and inherited-handle configuration.
- Removes an unused OpenAPI test helper and preserves an older-framework compatibility path.
Validation of the final revision remains limited; full cross-platform and browser E2E validation has not been completed.
| File | Description |
|---|---|
src/Tools/Shared/TestHelpers/NativeAotToolRunner.cs |
Uses combined output capture and exit-status waits. |
src/Tools/Shared/SecretsHelpers/ProjectIdResolver.cs |
Replaces event-based capture with RunAndCaptureText. |
src/Tools/Microsoft.dotnet-openapi/test/ProcessEx.cs |
Removes the unused process wrapper. |
src/Tools/Microsoft.dotnet-openapi/src/Commands/BaseCommand.cs |
Captures package-install output asynchronously with a timeout. |
src/Tools/dotnet-getdocument/src/Exe.cs |
Uses a kill-on-timeout wait and returned exit status. |
src/SignalR/server/StackExchangeRedis/test/Docker.cs |
Kills timed-out commands and uses exit-status results. |
src/SignalR/perf/benchmarkapps/Crankier/Agent.cs |
Sends unread worker stderr to a null handle. |
src/Shared/Process/ProcessExtensions.cs |
Uses built-in output capture with a timeout. |
src/Shared/Process/ProcessEx.cs |
Sets an explicit inherited-handle list. |
src/Shared/E2ETesting/SauceConnectServer.cs |
Configures handle inheritance for tunnel and sentinel launches. |
src/Shared/CertificateGeneration/UnixCertificateManager.cs |
Sets inherited-handle lists for certificate commands. |
src/Shared/CertificateGeneration/MacOSCertificateManager.cs |
Updates handle inheritance and certificate-command exit waiting. |
src/Servers/Kestrel/test/Interop.FunctionalTests/H2SpecCommands.cs |
Replaces manual exit tracking with a cancellation-aware wait. |
src/Servers/IIS/IntegrationTesting.IIS/src/IISExpressDeployer.cs |
Uses parent-exit cleanup and exit-status waits. |
src/Servers/IIS/IIS/test/Common.FunctionalTests/Infrastructure/Helpers.cs |
Uses a timed exit-status assertion. |
src/Servers/IIS/IIS/test/Common.FunctionalTests/Infrastructure/AppVerifier.cs |
Captures command output through the built-in runner. |
src/Servers/HttpSys/test/FunctionalTests/ServerTests.cs |
Removes duplicate process starts and awaits command exit. |
src/OpenApi/test/Microsoft.AspNetCore.OpenApi.Build.Tests/GenerateAdditionalXmlFilesForOpenApiTests.cs |
Combines output capture while retaining explicit tree cleanup. |
src/Middleware/WebSockets/test/ConformanceTests/Autobahn/Executable.cs |
Streams output lines and updates cancellation cleanup. |
src/Middleware/StaticFiles/test/UnitTests/StaticFileMiddlewareTests.cs |
Uses Process.Run with structured symlink arguments. |
src/Middleware/Spa/SpaServices.Extensions/src/Npm/NodeScriptRunner.cs |
Sets an explicit inherited-handle list. |
src/Middleware/Spa/SpaProxy/src/SpaProxyLaunchManager.cs |
Disposes shutdown-script wrappers and checks exit status. |
src/Hosting/test/FunctionalTests/ShutdownTests.cs |
Sends SIGTERM directly and uses a kill-on-timeout wait. |
src/Hosting/Server.IntegrationTesting/src/Deployers/SelfHostDeployer.cs |
Configures handle inheritance for hosted applications. |
src/Hosting/Server.IntegrationTesting/src/Deployers/RemoteWindowsDeployer/RemoteWindowsDeployer.cs |
Configures handle inheritance for PowerShell launches. |
src/Hosting/Server.IntegrationTesting/src/Deployers/NginxDeployer.cs |
Uses Environment.UserName and explicit timed exit checks. |
src/Hosting/Server.IntegrationTesting/src/ApplicationPublisher.cs |
Disposes the process wrapper and uses parent-only exit-status waits. |
src/Grpc/Interop/test/InteropTests/Helpers/WebsiteProcess.cs |
Configures handle inheritance for test servers. |
src/Grpc/Interop/test/InteropTests/Helpers/ClientProcess.cs |
Configures handle inheritance for test clients. |
src/Fuzzing/AspNetCoreFuzzing/Program.cs |
Configures handle inheritance for instrumentation commands. |
src/Components/WebView/test/StaticWebAssets/ConsumerBuild.cs |
Reads combined output lines within a shared timeout budget. |
src/Components/WebView/test/E2ETest/WebViewManagerE2ETests.cs |
Reads output asynchronously and disposes the process wrapper. |
src/Components/WebAssembly/Server/src/DebugProxyLauncher.cs |
Simplifies startup and timeout-registration disposal. |
src/Components/Testing/test/PackageIntegrationTests.cs |
Drains output concurrently and kills the app on readiness failure. |
src/Components/Testing/src/Infrastructure/ServerInstance.cs |
Uses exit-status waits for readiness monitoring and disposal. |
src/Components/Testing/src/Infrastructure/ParentProcessWatcher.cs |
Uses process lookup and an asynchronous wait instead of polling. |
src/Components/Gateway/test/GatewayToolInstallation.cs |
Uses timed output enumeration and exit-status waits. |
src/Caching/StackExchangeRedis/test/Infrastructure/RedisTestConfig.cs |
Adds .NET 11 handle configuration behind a framework guard. |
.github/skills/review-pull-request/tests/PrepareReviewTests.cs |
Captures Git stdout and stderr together as bytes. |
.github/skills/review-pull-request/scripts/prepare-review.cs |
Updates handle inheritance and process-start handling. |
Review effort: Balanced
adamsitnik
left a comment
There was a problem hiding this comment.
I've left comments, so other reviewers can understand the reasoning behind the changes and avoid similar issues in the future.
|
Looks like this PR hasn't been active for some time and the codebase could have been changed in the meantime. |
373b346 to
9521117
Compare
741e3a0 to
373b346
Compare
Revert product improvements and test/infrastructure changes, which moved to separate PRs. Keep only the three product bug fixes: - dotnet-openapi: drain redirected output while adding a package, so a full pipe no longer blocks the child and surfaces as a false timeout. - Components.Testing ParentProcessWatcher: dispose the parent Process wrapper. - SpaProxy: dispose the shutdown-script Process wrappers. Co-authored-by: Copilot <[email protected]> Copilot-Session: 151a6a4b-fb9b-4efa-bb7c-383fe6bc3a4c
…ation The output-draining fix belongs to dotnet#70076. Co-authored-by: Copilot <[email protected]> Copilot-Session: 151a6a4b-fb9b-4efa-bb7c-383fe6bc3a4c
| var timeout = 20; | ||
| if (!process.WaitForExit(timeout * 1000)) |
There was a problem hiding this comment.
to other code reviewers: this was a bug: waiting for exit and then reading std out and then reading std err.
We must read both std out and err at the same time and then wait for exit. Which is what Process.RunAndCaptureTextAsync does
@akoeplinger done! This PR is now just product bug fixes, and #70669 and contain #70668 other changes. |
There was a problem hiding this comment.
🟡 Changes recommended
The missing large-output regression test leaves the real dotnet add package path without coverage to detect the original pipe-buffer hang and confirm failure diagnostics are returned instead of a timeout.
1 open issue
Review effort: Balanced
DeagleGross
left a comment
There was a problem hiding this comment.
LGTM, lets add a test to lockdown the behavior
|
✅ No documentation PR was created. Confidence that documentation is needed: 5% No docs needed: internal bug fixes (dotnet-openapi output draining, Process wrapper disposal); no public API changes. Documentation surfaces considered
|
Resolve conflicts with dotnet#70076 in ParentProcessWatcher and SpaProxyLaunchManager by keeping this branch's versions, which already include its process wrapper disposal. Co-authored-by: Copilot <[email protected]> Copilot-Session: 151a6a4b-fb9b-4efa-bb7c-383fe6bc3a4c

Fix product process-output hang and process-wrapper leaks
Fix an output-pipe hang in dotnet-openapi and release leaked Process wrappers.
Description
Following review feedback, this PR now contains only product bug fixes, so they can be considered for backporting. The rest of the original changes moved to separate PRs:
The original commits are kept in the history; the last commit reverts everything except the fixes below.
Bug fixes
dotnet add packageto exit before reading its redirected stdout/stderr. When the command produced enough output to fill a pipe, the child blocked and the tool reported a false 20-second timeout instead of the actual failure. The output is now drained while the command runs; the existing timeout message and package-reference fallback are preserved, and a timed-out command is cleaned up.ParentProcessWatcher: dispose the monitored parentProcesswrapper. Polling and shutdown behavior are unchanged.Processwrappers. This releases wrapper resources only; it does not stop the shutdown scripts and does not fix the existing check-after-start timing race.No public API changes. The OpenAPI fix uses the .NET 11
Process.RunAndCaptureTextAsyncAPI, so a backport to older releases would need a different implementation.This work started as a real-world test of the
process-api-net11skill in dotnet/skills#1322.Validation
On Windows, with the same file content on a branch based on main:
dotnet test src\Tools\Microsoft.dotnet-openapi\test\dotnet-microsoft.openapi.Tests.csproj --filter 'FullyQualifiedName~OpenApiAddFileTests'— passed.Microsoft.AspNetCore.Components.TestingandMicrosoft.AspNetCore.SpaProxy— built successfully.The two disposal fixes have no dedicated tests. macOS/Linux SPA shutdown-script behavior was not runtime-tested.
Related issue: none linked.