diff --git a/.autover/changes/cd8cd757-830a-4abd-b01f-92176e837b07.json b/.autover/changes/cd8cd757-830a-4abd-b01f-92176e837b07.json new file mode 100644 index 000000000..a2c6ea053 --- /dev/null +++ b/.autover/changes/cd8cd757-830a-4abd-b01f-92176e837b07.json @@ -0,0 +1,11 @@ +{ + "Projects": [ + { + "Name": "Amazon.Lambda.RuntimeSupport", + "Type": "Patch", + "ChangelogMessages": [ + "Revert behavor for non SnapShot scenario to throw an exception when initialize fails" + ] + } + ] +} \ No newline at end of file diff --git a/Libraries/src/Amazon.Lambda.RuntimeSupport/Bootstrap/LambdaBootstrap.cs b/Libraries/src/Amazon.Lambda.RuntimeSupport/Bootstrap/LambdaBootstrap.cs index fa7996a84..e0ac20907 100644 --- a/Libraries/src/Amazon.Lambda.RuntimeSupport/Bootstrap/LambdaBootstrap.cs +++ b/Libraries/src/Amazon.Lambda.RuntimeSupport/Bootstrap/LambdaBootstrap.cs @@ -219,8 +219,8 @@ internal async Task InitializeAsync() System.Environment.Exit(1); // This needs to be non-zero for Lambda Sandbox to know that Runtime client encountered an exception } #endif + throw; } - return false; } internal async Task InvokeOnceAsync(CancellationToken cancellationToken = default) diff --git a/Libraries/test/Amazon.Lambda.RuntimeSupport.Tests/Amazon.Lambda.RuntimeSupport.UnitTests/LambdaBootstrapTests.cs b/Libraries/test/Amazon.Lambda.RuntimeSupport.Tests/Amazon.Lambda.RuntimeSupport.UnitTests/LambdaBootstrapTests.cs index 44f20aa7e..cafd83fe4 100644 --- a/Libraries/test/Amazon.Lambda.RuntimeSupport.Tests/Amazon.Lambda.RuntimeSupport.UnitTests/LambdaBootstrapTests.cs +++ b/Libraries/test/Amazon.Lambda.RuntimeSupport.Tests/Amazon.Lambda.RuntimeSupport.UnitTests/LambdaBootstrapTests.cs @@ -83,14 +83,23 @@ public async Task NoInitializer() } [Fact] - public async Task InitializerHandlesExceptionsGracefully() + public async Task InitializerHandlesExceptions() { + bool exceptionThrown = false; using (var bootstrap = new LambdaBootstrap(_testFunction.BaseHandlerAsync, _testInitializer.InitializeThrowAsync)) { bootstrap.Client = _testRuntimeApiClient; - await bootstrap.RunAsync(); + try + { + await bootstrap.RunAsync(); + } + catch + { + exceptionThrown = true; + } } + Assert.True(exceptionThrown); Assert.True(_testRuntimeApiClient.ReportInitializationErrorAsyncExceptionCalled); Assert.True(_testInitializer.InitializerWasCalled); Assert.False(_testFunction.HandlerWasCalled);