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
#2383) (#2472)

Co-authored-by: Kris Borowinski <kris.borowinski@outlook.com>
  • Loading branch information
github-actions[bot] and kborowinski authored May 20, 2024
1 parent eaa36ae commit 16f0f3b
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 16f0f3b

Please sign in to comment.