You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Plugin processes inherit the host's stderr; callers capturing output hang when a plugin outlives restore #15163
Summary PluginFactory starts plugins with RedirectStandardError = false, so a plugin inherits the stderr of the process that runs restore. If the plugin outlives its host, it keeps the caller's stderr pipe open. Any caller that redirects output and waits for EOF hangs. In the .NET VMR, dotnet new webapi exited 0 and the scenario test then waited until the 30-min CI timeout (dotnet/dotnet#11442).
Mechanism (NuGet.Client 496ae9d46a, as built into .NET SDK 12.0.100-alpha.1.26577.103)
PluginFactory.cs:188,202: plugins start with stdin/stdout redirected and RedirectStandardError = false, so fd 2 is the host's stderr.
PluginFactory.cs:80: end-of-build dispose only closes plugins whose creation task is RanToCompletion. A plugin still starting is never closed. (Possible trigger; unproven because the dump has no heap and plugin logging was off.)
Plugin side (CredentialProvider.Microsoft using NuGet.Protocol 6.7.1): stdin EOF only ends the read loop (StandardInputReceiver) and doesn't close the connection; the idle timeout is infinite.
Result: the host exits, and the plugin (ppid=1) lives on holding the caller's stderr pipe.
Evidence
CI hang report. The child exited 0, but output never reached EOF. The only pipe holder: pid=135653 ppid=1 state=S/futex_wait_queue pipes=pipe:[750745] .../dotnet .../CredentialProvider.Microsoft/CredentialProvider.Microsoft.dll -Plugin
Plugin core dump: the only managed threads are main (Program.<Main> blocked in GetResult), finalizer, thread-pool gate and timer. There is no host-exit monitor thread.
Local repro (WSL, credential provider v1.1.0): when the host exits after the handshake without disposing the plugin or completing MonitorNuGetProcessExit, the plugin keeps fd 2 on the host's stderr pipe and never exits.
Suggested fix
Don't let plugins inherit stderr: RedirectStandardError = true and drain it (all TFMs), or on .NET 11+ StandardErrorHandle = File.OpenNullHandle() (or a pipe forwarded to the plugin log).
Windows: CreateProcess uses bInheritHandles = true, so the plugin can still inherit the host's inheritable stdout/stderr handles. On .NET 11+, also set InheritedHandles = [].
Optional: KillOnParentExit = true (.NET 11+, Linux/Windows), and dispose plugins whose creation is still in flight at end of build. Both prevent orphaned plugins.
On Unix the first item alone removes the hang, because only fds 0–2 are passed to the child.
Another data point from outside the VMR: macOS (Darwin 25.5.0), .NET SDK 10.0.300 (NuGet 7.6.0), CredentialProvider.Microsoft 2.0.4, with two credential provider plugins registered (the netcore plugin folder and the dotnet tool).
The caller is rtk, which captures output and waits for EOF (rtk-ai/rtk#2320). In a hung run, dotnet build had exited after "Build succeeded" in about 5 s, and an orphaned CredentialProvider.Microsoft.dll -Plugin (ppid=1) was still running 17 minutes later. The plugin log in the binlog shows a normal exchange: Initialize, GetOperationClaims, SetLogLevel, then GetAuthenticationCredentials answered from the session token cache in 10 ms. It happened in 6 of 24 runs. I could not reproduce it on demand, so I have no lsof or dump.
Activity
dotnet-policy-service commentedon Nov 30, 2026
Issue is missing Type label, remember to add a Type label
jeroenkoknl commentedon Dec 4, 2026
Another data point from outside the VMR: macOS (Darwin 25.5.0), .NET SDK 10.0.300 (NuGet 7.6.0), CredentialProvider.Microsoft 2.0.4, with two credential provider plugins registered (the netcore plugin folder and the dotnet tool).
The caller is rtk, which captures output and waits for EOF (rtk-ai/rtk#2320). In a hung run,
dotnet buildhad exited after "Build succeeded" in about 5 s, and an orphanedCredentialProvider.Microsoft.dll -Plugin(ppid=1) was still running 17 minutes later. The plugin log in the binlog shows a normal exchange: Initialize, GetOperationClaims, SetLogLevel, then GetAuthenticationCredentials answered from the session token cache in 10 ms. It happened in 6 of 24 runs. I could not reproduce it on demand, so I have no lsof or dump.Comment created with Claude Code.