Skip to content

Commit

Permalink
Add null check for $host.UI and its properties to avoid race condition (
Browse files Browse the repository at this point in the history
  • Loading branch information
kborowinski authored and github-actions committed May 20, 2024
1 parent eaa36ae commit 12de632
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/functions/Output.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -1162,7 +1162,8 @@ function Resolve-OutputConfiguration ([PesterConfiguration]$PesterPreference) {
# https://no-color.org/)
$PesterPreference.Output.RenderMode = 'Plaintext'
}
elseif (($supportsVT = $host.UI.psobject.Properties['SupportsVirtualTerminal']) -and $supportsVT.Value) {
# Null check $host.UI and its properties to avoid race condition when accessing them from multiple threads. https://github.com/pester/Pester/issues/2383
elseif ($null -ne $host.UI -and ($hostProperties = $host.UI.psobject.Properties) -and ($supportsVT = $hostProperties['SupportsVirtualTerminal']) -and $supportsVT.Value) {
$PesterPreference.Output.RenderMode = 'Ansi'
}
else {
Expand Down

0 comments on commit 12de632

Please sign in to comment.