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 committed May 18, 2024
1 parent c92e864 commit e4d2f1a
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 @@ -1127,7 +1127,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 e4d2f1a

Please sign in to comment.