-
Notifications
You must be signed in to change notification settings - Fork 7.6k
Fix Invoke-Command
missing error on session termination.
#11586
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
Fix Invoke-Command
missing error on session termination.
#11586
Conversation
This is a possible breaking change. Some job ending states that used to be 'Stopped' with Exception, will now be 'Failed' with Exception. But I feel this is the correct behavior. The only time a 'Stopped' state is not an error is if there is no associated exception, or the exception is 'PipelineStopped'. |
@PoshChan Please retry windows |
@PaulHigin, successfully started retry of |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
are there tests that can be added for this?
@JamesWTruher No, the repro is difficult to automate and still get the right error path. We don't need another fragile test. |
@PowerShell/powershell-committee reviewed this and agree that the scenario where the pipeline is stopped with an error that is not a PipelineStoppedException it is a failure case, so this change is accepted. |
@TravisEz13 This change created a subtle regression. Please hold off merging until I have pushed the fix. |
@SteveL-MSFT , @JamesWTruher Please re-review the changes. I have added a fix to the regression and also fixed the Stop-Job tests so that they will catch bad final state. The regression was due to the pipeline returning a RemoteException exception on a pipeline stop instead of a PipelineStoppedException exception I was previously checking. A pipeline stopped RemoteException will contain an ErrorRecord with FQEID of 'PipelineStopped'. The Stop-Job tests were not catching the incorrect final state because they ran before the job was actually running. Fix is to wait until job is running and returning data to the client. |
@SteveL-MSFT Please re-review. |
@SteveL-MSFT ping... |
Invoke-Command
missing error on session termination.
🎉 Handy links: |
PR Summary
This change fixes a problem in Invoke-Command against a remote session and that session is abruptly terminated, but no error is reported.
PR Context
In certain conditions, an abrupt session termination results in an Invoke-Command pipeline state going to 'Stopped' with an exception. Currently this is ignored in job processing because a user initiated stop is not an error. But a stopped state due to an error that is not 'PipelineStoppedException' (such as a remote transport exception) should not be ignored, but instead be treated as an error so that Invoke-Command will report it.
The fix is to update job error processing to correctly handle this error state.
Repro steps
PR Checklist
.h
,.cpp
,.cs
,.ps1
and.psm1
files have the correct copyright headerWIP:
or[ WIP ]
to the beginning of the title (theWIP
bot will keep its status check atPending
while the prefix is present) and remove the prefix when the PR is ready.