Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Message buffers are closed prematurely if you attempt to invoke a command in the host runspace while it is busy #10335

Closed
KirkMunro opened this issue Aug 9, 2019 · 3 comments
Labels
Issue-Bug Issue has been identified as a bug in the product Resolution-No Activity Issue has had no activity for 6 months or more WG-Engine core PowerShell engine, interpreter, and runtime

Comments

@KirkMunro
Copy link
Contributor

Attempting to invoke a command in the host runspace when it is busy incorrectly results in the message buffers being closed, which prevents further invocations from working properly if they write messages to those buffers.

Steps to reproduce

# Note: This uses the call operator because the commands must all be run in
# one shot to reproduce the issue.
& {
    $ps = [powershell]::Create()
    $ps.Runspace = $host.Runspace
    try {
        $ps.AddScript('Get-Date').Invoke() > $null
    } finally {
        $ps.Dispose()
    }

    [ScriptBlock]::Create({Write-Error 'An error'}).Invoke() > $null
}

Expected behavior

Exception calling "Invoke" with "0" argument(s): "The pipeline was not run because a pipeline is already running. Pipelines cannot be run concurrently."
At line:5 char:9
+         $ps.AddScript('Get-Date').Invoke() > $null
+         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : PSInvalidOperationException

Actual behavior

Exception calling "Invoke" with "0" argument(s): "The pipeline was not run because a pipeline is already running. Pipelines cannot be run concurrently."
At line:5 char:9
+         $ps.AddScript('Get-Date').Invoke() > $null
+         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : PSInvalidOperationException

Exception calling "Invoke" with "0" argument(s): "Objects cannot be added to a closed buffer. Make sure the buffer is open for Add and Insert operations to succeed."
At line:10 char:5
+     [ScriptBlock]::Create({Write-Error 'An error'}).Invoke() > $null
+     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : CmdletInvocationException

Environment data

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

Note: This also repros on PowerShell 5.1, so this is not a new issue.

@KirkMunro KirkMunro added the Issue-Question ideally support can be provided via other mechanisms, but sometimes folks do open an issue to get a label Aug 9, 2019
@KirkMunro KirkMunro mentioned this issue Aug 9, 2019
11 tasks
@iSazonov iSazonov added WG-Engine core PowerShell engine, interpreter, and runtime Issue-Bug Issue has been identified as a bug in the product and removed Issue-Question ideally support can be provided via other mechanisms, but sometimes folks do open an issue to get a labels Jan 30, 2020
@Scherlac
Copy link

Scherlac commented Jun 14, 2023

Is this issue related to the following topics:

proxb/PoshRSJob#127

Copy link
Contributor

This issue has not had any activity in 6 months, if there is no further activity in 7 days, the issue will be closed automatically.

Activity in this case refers only to comments on the issue. If the issue is closed and you are the author, you can re-open the issue using the button below. Please add more information to be considered during retriage. If you are not the author but the issue is impacting you after it has been closed, please submit a new issue with updated details and a link to this issue and the original.

1 similar comment
Copy link
Contributor

This issue has not had any activity in 6 months, if there is no further activity in 7 days, the issue will be closed automatically.

Activity in this case refers only to comments on the issue. If the issue is closed and you are the author, you can re-open the issue using the button below. Please add more information to be considered during retriage. If you are not the author but the issue is impacting you after it has been closed, please submit a new issue with updated details and a link to this issue and the original.

@microsoft-github-policy-service microsoft-github-policy-service bot added Resolution-No Activity Issue has had no activity for 6 months or more labels Dec 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Issue-Bug Issue has been identified as a bug in the product Resolution-No Activity Issue has had no activity for 6 months or more WG-Engine core PowerShell engine, interpreter, and runtime
Projects
None yet
Development

No branches or pull requests

3 participants