-
Notifications
You must be signed in to change notification settings - Fork 8.1k
Closed
Labels
Issue-Discussionthe issue may not have a clear classification yet. The issue may generate an RFC or may be reclassifthe issue may not have a clear classification yet. The issue may generate an RFC or may be reclassifIssue-Enhancementthe issue is more of a feature request than a bugthe issue is more of a feature request than a bugResolution-FixedThe issue is fixed.The issue is fixed.WG-Languageparser, language semanticsparser, language semantics
Milestone
Description
Was discussing with @jpsnover a concern that if a cmdlet opens a resource (like a database connection) in Begin, and later in the pipeline an exception is thrown, End is not called to dispose of the connection.
Steps to reproduce
function a {
[cmdletbinding()]
param()
begin { "a:begin" }
process { 1 }
end { "a:end" }
}
function b {
[cmdletbinding()]
param([parameter(ValueFromPipeline=$true)]$a)
begin { "b:begin" }
process { $a; throw 'oops' }
}
a | bExpected behavior
b:begin
a:begin
a:end
oops
At /Users/steve/test/end_not_called.ps1:15 char:19
+ process { $a; throw "oops" }
+ ~~~~~~~~~~~~ + CategoryInfo : OperationStopped: (oops:String) [], RuntimeException
+ FullyQualifiedErrorId : oops
Actual behavior
b:begin
a:begin
oops
At /Users/steve/test/end_not_called.ps1:15 char:19
+ process { $a; throw "oops" }
+ ~~~~~~~~~~~~ + CategoryInfo : OperationStopped: (oops:String) [], RuntimeException
+ FullyQualifiedErrorId : oops
Environment data
Name Value
---- -----
PSVersion 6.1.0-preview.1
PSEdition Core
GitCommitId v6.1.0-preview.1
OS Darwin 17.5.0 Darwin Kernel Version 17.5.0: Mon Mar 5 22:24:32 PST 2018; root:xnu-4570.51.1~1/RELEASE_X86_64
Platform Unix
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0markekraus, dragonwolf83, kborowinski, mi-hol, paulomorgado and 8 more
Metadata
Metadata
Assignees
Labels
Issue-Discussionthe issue may not have a clear classification yet. The issue may generate an RFC or may be reclassifthe issue may not have a clear classification yet. The issue may generate an RFC or may be reclassifIssue-Enhancementthe issue is more of a feature request than a bugthe issue is more of a feature request than a bugResolution-FixedThe issue is fixed.The issue is fixed.WG-Languageparser, language semanticsparser, language semantics