You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
PowerShell.EndInvoke(IAsyncResult) doesn't provide a way for users to get the partial results when a terminating error is thrown #8005
Issue-Discussionthe issue may not have a clear classification yet. The issue may generate an RFC or may be reclassifResolution-No ActivityIssue has had no activity for 6 months or moreWG-Enginecore PowerShell engine, interpreter, and runtime
When a terminating error is thrown from the script, PowerShell.EndInvoke(IAsyncResult) will throw the exception and there is no way to get the partial results back (output from before the terminating error).
It would be good to make it able to return the partial results when a terminating error is thrown.
Throw the exception, but at the same time allow the users to get the partial results back.
Actual behavior
Exception is thrown, $b is null, and the partial output is lost.
Environment data
>$PSVersionTable
Name Value
---------
PSVersion 6.1.0
PSEdition Core
GitCommitId 6.1.0
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
I feel this is fundamentally broken because if a terminating error occurs (including stop) then any data generated up to that point is lost ... a major sin in my book.
Some ideas to remedy:
Catch pipeline stop exception and insert into Error stream as non-terminating error. But this doesn't address a general terminating exception.
Catch all terminating exceptions (in EndInvoke) and insert into Error stream, marking the error as terminating in some way.
Create a new "EndInvoke" exception class that is thrown, which wraps the actual terminating error and also provides the output buffer as a parameter.
-> I would think you typically wouldn't want output from a failed invocation
It seems to me to be just the opposite. For a long running script I would want to get all output information occurring before a terminating error. It would help understand what happened, what may have caused the error, and what state the machine is in.
For a long running script I would want to get all output information occurring before a terminating error. It would help understand what happened, what may have caused the error, and what state the machine is in.
I'm inclined to agree that having output information would be useful in the initial stages of development and testing. Once the code is in use I think it would be more common to rethrow or change code paths (and if you do absolutely need it, the other overload is still available to you).
That said, my main concern isn't really about the output and more about changing the behavior of EndInvoke.
Since the output collection is stored internally on the PowerShellAsyncResult returned by BeginInvoke, would it make sense to instead have a new method that can retrieve the output? e.g.
i agree, this is very important to have a method to get the output so far, likewise there is no way to abort and still capture the output. if i issue EndInvoke it will wait for the job. but if i call stop to terminate it, i have no way to get the output up until that point. there should also be a way to get the breaking exception.
microsoft-github-policy-service commented on Nov 16, 2023
This issue has not had any activity in 6 months, if this is a bug please try to reproduce on the latest version of PowerShell and reopen a new issue and reference this issue if this is still a blocker for you.
microsoft-github-policy-service commented on Nov 16, 2023
This issue has not had any activity in 6 months, if this is a bug please try to reproduce on the latest version of PowerShell and reopen a new issue and reference this issue if this is still a blocker for you.
microsoft-github-policy-service commented on Nov 16, 2023
This issue has not had any activity in 6 months, if this is a bug please try to reproduce on the latest version of PowerShell and reopen a new issue and reference this issue if this is still a blocker for you.
Issue-Discussionthe issue may not have a clear classification yet. The issue may generate an RFC or may be reclassifResolution-No ActivityIssue has had no activity for 6 months or moreWG-Enginecore PowerShell engine, interpreter, and runtime
Activity
daxian-dbw commentedon Oct 11, 2018
Move Paul Higinbotham (@PaulHigin)'s comment on this issue from #7917 (comment)
SeeminglyScience commentedon Oct 12, 2018
Wouldn't that be expected behavior? A script would work the same way
I would think you typically wouldn't want output from a failed invocation, but there's always this overload for when you do
PaulHigin commentedon Oct 15, 2018
-> I would think you typically wouldn't want output from a failed invocation
It seems to me to be just the opposite. For a long running script I would want to get all output information occurring before a terminating error. It would help understand what happened, what may have caused the error, and what state the machine is in.
SeeminglyScience commentedon Oct 15, 2018
I'm inclined to agree that having output information would be useful in the initial stages of development and testing. Once the code is in use I think it would be more common to rethrow or change code paths (and if you do absolutely need it, the other overload is still available to you).
That said, my main concern isn't really about the output and more about changing the behavior of
EndInvoke.Since the output collection is stored internally on the
PowerShellAsyncResultreturned byBeginInvoke, would it make sense to instead have a new method that can retrieve the output? e.g.lachlann562 commentedon Jan 15, 2019
i agree, this is very important to have a method to get the output so far, likewise there is no way to abort and still capture the output. if i issue EndInvoke it will wait for the job. but if i call stop to terminate it, i have no way to get the output up until that point. there should also be a way to get the breaking exception.
microsoft-github-policy-service commentedon Nov 16, 2023
This issue has not had any activity in 6 months, if this is a bug please try to reproduce on the latest version of PowerShell and reopen a new issue and reference this issue if this is still a blocker for you.
microsoft-github-policy-service commentedon Nov 16, 2023
This issue has not had any activity in 6 months, if this is a bug please try to reproduce on the latest version of PowerShell and reopen a new issue and reference this issue if this is still a blocker for you.
microsoft-github-policy-service commentedon Nov 16, 2023
This issue has not had any activity in 6 months, if this is a bug please try to reproduce on the latest version of PowerShell and reopen a new issue and reference this issue if this is still a blocker for you.
microsoft-github-policy-service commentedon Nov 23, 2023
This issue has been marked as "No Activity" as there has been no activity for 6 months. It has been closed for housekeeping purposes.