Fix Invoke-Command missing error on session termination.#11586
Fix Invoke-Command missing error on session termination.#11586TravisEz13 merged 4 commits intoPowerShell:masterfrom PaulHigin:fix-missing-error-invokecommand
Invoke-Command missing error on session termination.#11586Conversation
|
@PoshChan Please retry windows |
|
@PaulHigin, successfully started retry of |
JamesWTruher
left a comment
There was a problem hiding this comment.
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.

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,.ps1and.psm1files have the correct copyright headerWIP:or[ WIP ]to the beginning of the title (theWIPbot will keep its status check atPendingwhile the prefix is present) and remove the prefix when the PR is ready.