Skip to content

Duplicated Verbose Messages on StreamingHost of Receive-Job with Wait and Verbose flags present #26661

@thoffmannaspenware

Description

@thoffmannaspenware

Prerequisites

Steps to reproduce

The following code produces duplicate verbose messages. During a large job, this can amount to gigabytes of logs:

$job = Start-ThreadJob -StreamingHost $Host -ScriptBlock {
    Write-Verbose "yo" -Verbose
    Start-Sleep -Seconds 2
}
Receive-Job -Job $job -Wait -Verbose

Also can reproduce with Write-Debug:

$job = Start-ThreadJob -StreamingHost $Host -ScriptBlock {
    Write-Debug "yo" -Debug
    Start-Sleep -Seconds 2
}
Receive-Job -Job $job -Wait -Debug

Other ways of reproducing:

Start-ThreadJob -StreamingHost $Host -ScriptBlock { Write-Verbose "yo" -Verbose; Start-Sleep -Seconds 1 } | Receive-Job -Wait -Verbose

This seems to require the following elements to reproduce:

  • A threadjob with streaminghost, or at least a streaminghost.
  • Forced Write-Verbose or other stream forced command inside the threadjob (e.g. Write-Verbose "yo" -Verbose)
  • Receive job -Wait -Verbose or similar stream (debug works too)
  • Don't wait for the job (if you wait prior to receive job commandlet, it will not reproduce). Receive job must do the waiting

Expected behavior

VERBOSE: yo

Actual behavior

VERBOSE: yo
VERBOSE: yo
VERBOSE: yo
VERBOSE: yo
VERBOSE: yo
VERBOSE: yo
VERBOSE: yo
VERBOSE: yo
VERBOSE: yo
VERBOSE: yo
VERBOSE: yo
VERBOSE: yo
VERBOSE: yo
VERBOSE: yo
VERBOSE: yo
VERBOSE: yo
VERBOSE: yo
VERBOSE: yo
VERBOSE: yo
VERBOSE: yo
VERBOSE: yo
VERBOSE: yo
VERBOSE: yo
VERBOSE: yo
VERBOSE: yo
VERBOSE: yo
VERBOSE: yo
VERBOSE: yo
VERBOSE: yo
VERBOSE: yo
VERBOSE: yo
VERBOSE: yo
VERBOSE: yo
VERBOSE: yo
VERBOSE: yo
VERBOSE: yo
VERBOSE: yo
VERBOSE: yo
VERBOSE: yo
VERBOSE: yo
VERBOSE: yo
VERBOSE: yo
VERBOSE: yo
VERBOSE: yo
VERBOSE: yo
VERBOSE: yo
VERBOSE: yo
VERBOSE: yo
VERBOSE: yo
VERBOSE: yo
VERBOSE: yo
VERBOSE: yo
VERBOSE: yo
VERBOSE: yo
VERBOSE: yo
VERBOSE: yo
VERBOSE: yo
VERBOSE: yo
VERBOSE: yo
VERBOSE: yo
VERBOSE: yo
VERBOSE: yo
VERBOSE: yo
VERBOSE: yo
VERBOSE: yo

Error details

N/A

Environment data

Powershell version:

PS C:\git> $psversiontable

Name                           Value
----                           -----
PSVersion                      7.5.4
PSEdition                      Core
GitCommitId                    7.5.4
OS                             Microsoft Windows 10.0.26200
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

We also reproduced on 2 machines, 7.5.3 and 7.5.4, and Azure cloud shell

Visuals

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Needs-TriageThe issue is new and needs to be triaged by a work group.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions