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
pwsh never exits after Import-Module CompletionPredictor when output is redirected and nothing is written #39
Make sure you are able to repro it on the latest version (CompletionPredictor 0.1.1)
Search the existing issues. (Checked all 12 open and closed issues; none is about pwsh not exiting.)
Steps to reproduce
When pwsh runs with redirected stdout/stderr (as scripts, editor tasks and other tools launch it), importing CompletionPredictor makes the process hang forever at exit, as long as the command writes no output. Writing any output ("x" or Write-Host x), before or after the import, avoids the hang.
The same hang happens when the import is in $PROFILE. Then even pwsh -Command exit from a script never returns.
Workaround: import the module only in interactive sessions, e.g. in $PROFILE:
if (-not [Console]::IsOutputRedirected -and-not ([Environment]::GetCommandLineArgs() -match'^-(c|command|f|file|noninteractive)$')) {
Import-Module CompletionPredictor
}
Expected behavior
PS> # script aboveexited
The pwsh process exits right away (about 0.5 s).
Actual behavior
PS> # script aboveHUNG
The pwsh process never exits. In one run it was still stuck after 90 s, with 0.73 s of CPU time and 24 threads.
Error details
No error is shown; the process just never exits.
Environment data
Name Value
---------
PSVersion 7.6.6
PSEdition Core
GitCommitId 7.6.6
OS Microsoft Windows 10.0.26300
Platform Win32NT
PSCompatibleVersions {1.0,2.0,3.0,4.0.}
PSRemotingProtocolVersion 2.4
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
Also: PSReadLine 2.4.5, .NET 10.0.12, PowerShell installed from the Microsoft Store. Not tested on earlier PowerShell versions.
Activity