From 87b3035eda0cdd3f0d64803aadd4abfcac97b60e Mon Sep 17 00:00:00 2001 From: HetCreep Date: Mon, 22 Jun 2026 00:08:21 +0700 Subject: [PATCH] fix(threading): surface runspace errors instead of swallowing them in GUI mode (#655) --- Scripts/Threading/Invoke-NonBlocking.ps1 | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/Scripts/Threading/Invoke-NonBlocking.ps1 b/Scripts/Threading/Invoke-NonBlocking.ps1 index 2799ded..b2d02ac 100644 --- a/Scripts/Threading/Invoke-NonBlocking.ps1 +++ b/Scripts/Threading/Invoke-NonBlocking.ps1 @@ -45,6 +45,15 @@ function Invoke-NonBlocking { $result = $ps.EndInvoke($handle) + # Surface non-terminating errors raised inside the runspace so GUI-mode operations + # (e.g. failed app removals) don't fail silently - the runspace keeps its own error + # stream that is otherwise discarded on Dispose. + if ($ps.HadErrors) { + foreach ($runspaceError in $ps.Streams.Error) { + Write-Error -ErrorRecord $runspaceError + } + } + if ($result.Count -eq 0) { return $null } if ($result.Count -eq 1) { return $result[0] } return @($result)