Note: I can only reproduce this reliably on macOS 10.15.4.
I see it occasionally on Ubuntu 18.04, and can never reproduce it on Windows.
It may be connected to using Start-Sleep inside the script block; not sure if the fact that a custom class is used across thread boundaries is relevant [update: it is]
Steps to reproduce
class Foo { static [object] Echo($val) { return $val } }
$cls = [Foo]
while ($true) {
$res = 1..10 | ForEach-Object -Parallel {
Start-Sleep -ms 100; ($using:cls)::echo($_)
} | Sort-Object
Compare-Object $res (1..10) | Should -BeNullOrEmpty
Write-Host -NoNewline .
}
Expected behavior
The loop should run indefinitely, because the test should alway succeed.
Actual behavior
The loop eventually - after a varying number of iterations - breaks due to intermittent test failures, stemming from a missing output; e.g.:
Expected $null or empty, but got @(@{InputObject=5; SideIndicator==>})
That is, not all input objects were echoed.
Environment data
PowerShell Core 7.1.0-preview.3 on macOS 10.15.4
Note: I can only reproduce this reliably on macOS 10.15.4.
I see it occasionally on Ubuntu 18.04, and can never reproduce it on Windows.
It may be connected to using
Start-Sleepinside the script block; not sure if the fact that a custom class is used across thread boundaries is relevant [update: it is]Steps to reproduce
Expected behavior
The loop should run indefinitely, because the test should alway succeed.
Actual behavior
The loop eventually - after a varying number of iterations - breaks due to intermittent test failures, stemming from a missing output; e.g.:
That is, not all input objects were echoed.
Environment data