Skip to content

Invoke-RestMethod parallel problem #15513

@dperez83

Description

@dperez83

Steps to reproduce

It happens randomly. Most of the time it works. Sometimes it fails and no other Invoke-RestMethod is possible after.

1..10 | ForEach-Object -Parallel { Invoke-RestMethod -Uri "www.google.com" -Headers @{
                 "method"="GET"
                 "scheme"="https"
                  } 
 } -ThrottleLimit 3

Expected behavior

To work everytime without the concurrent update error.

Actual behavior

Sometimes it returns the error bellow, and no further Invoke-RestMethod is possible in the session (it always returns the very same error) :

Invoke-RestMethod: Operations that change non-concurrent collections must have exclusive access. A concurrent update was performed on this collection and corrupted its state. The collection's state is no longer correct.

Environment data

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Issue-BugIssue has been identified as a bug in the productResolution-FixedThe issue is fixed.WG-Cmdlets-Corecmdlets in the Microsoft.PowerShell.Core module

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions