Skip to content

Fix 'using module' when module has non-terminating errors handled with 'SilentlyContinue' - #4711

Merged
Dongbo Wang (daxian-dbw) merged 1 commit into
PowerShell:masterfrom
daxian-dbw:loadmodule
Sep 1, 2017
Merged

Dongbo Wang (daxian-dbw) merged 1 commit into
PowerShell:masterfrom
daxian-dbw:loadmodule

Conversation

@daxian-dbw

Copy link
Copy Markdown
Member

Attempt to fix #4695

Compiler.LoadModule assumes that when ps.HadErrors == true the error stream is not empty. However, when SilentlyContinue is specified as the error action, the non-terminating error is not kept in ErrorOutputPipe of the cmdlet and thus does not appear in ps.Streams.Error. So when ps.HadErrors == true while ps.Streams.Error is empty, it suggests it's OK to ignore the errors because they are explicitly suppressed with SilentlyContinue error action.

So in my opinion, the expected behavior of "using module .\mod.psm1" in this case should be successful, as if ps.HaddErrors is false.

@SteveL-MSFT Steve Lee (SteveL-MSFT) left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@iSazonov Ilya (iSazonov) left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Leave a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@daxian-dbw
Dongbo Wang (daxian-dbw) merged commit 795de73 into PowerShell:master Sep 1, 2017
@daxian-dbw
Dongbo Wang (daxian-dbw) deleted the loadmodule branch September 1, 2017 15:54
@daxian-dbw

Copy link
Copy Markdown
Member Author

Thanks all for the review!

Thatgfsj (Thatgfsj) pushed a commit to Thatgfsj-contribs/PowerShell that referenced this pull request Aug 6, 2026
…h 'SilentlyContinue' (PowerShell#4711)

`Compiler.LoadModule` assumes that when `ps.HadErrors == true` the error stream is not empty. However, when `SilentlyContinue` is specified as the error action, the non-terminating error is not kept in `ErrorOutputPipe` of the cmdlet and thus does not appear in `ps.Streams.Error`. So when `ps.HadErrors == true` while `ps.Streams.Error` is empty, it suggests it's OK to ignore the errors because they are explicitly suppressed with `SilentlyContinue` error action.

So in my opinion, the expected behavior of `"using module .\mod.psm1"` in this case should be successful as if `ps.HaddErrors` is false.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ArgumentOutOfRangeException in Compiler.LoadModule

6 participants