diff --git a/RELEASE.CHANGELOG.md b/RELEASE.CHANGELOG.md index b3927ae..757a241 100644 --- a/RELEASE.CHANGELOG.md +++ b/RELEASE.CHANGELOG.md @@ -1,3 +1,7 @@ +### Jun 10, 2025 +`3.1.3` +- Handle Signal Exceptions during Runtime API Http Requests Gracefully and Version Bump to 3.1.3 ([#50](https://github.com/aws/aws-lambda-ruby-runtime-interface-client/pull/50)) + ### Jun 6, 2025 `3.1.2` - Don't Ignore Custom Formatters. ([#49](https://github.com/aws/aws-lambda-ruby-runtime-interface-client/pull/49)) diff --git a/lib/aws_lambda_ric/lambda_server.rb b/lib/aws_lambda_ric/lambda_server.rb index c5850ed..b4e0070 100644 --- a/lib/aws_lambda_ric/lambda_server.rb +++ b/lib/aws_lambda_ric/lambda_server.rb @@ -33,6 +33,8 @@ def next_invocation "Received #{resp.code} when waiting for next invocation." ) end + rescue SignalException => sig + raise LambdaErrors::InvocationError.new("Next invocation HTTP request from the runtime interface client was interrupted with a #{sig} SIGNAL, gracefully shutting down.") rescue LambdaErrors::InvocationError => e raise e rescue StandardError => e diff --git a/lib/aws_lambda_ric/version.rb b/lib/aws_lambda_ric/version.rb index 8c8c8af..c4b5704 100644 --- a/lib/aws_lambda_ric/version.rb +++ b/lib/aws_lambda_ric/version.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true module AwsLambdaRIC - VERSION = '3.1.2' + VERSION = '3.1.3' end diff --git a/test/unit/lambda_server_test.rb b/test/unit/lambda_server_test.rb index fb2e248..d08bc9f 100644 --- a/test/unit/lambda_server_test.rb +++ b/test/unit/lambda_server_test.rb @@ -15,6 +15,23 @@ def setup @under_test = RapidClient.new(@server_address, @mock_user_agent) end + def test_next_invocation_handles_different_signals + ['INT', 'TERM', 'QUIT'].each do |signal| + http_mock = Minitest::Mock.new + http_mock.expect(:read_timeout=, nil, [RapidClient::LONG_TIMEOUT_MS]) + http_mock.expect(:start, nil) { raise SignalException.new(signal) } + + Net::HTTP.stub :new, http_mock do + error = assert_raises(LambdaErrors::InvocationError) do + @under_test.next_invocation + end + + assert_match(/Next invocation HTTP request from the runtime interface client was interrupted with a SIG#{signal} SIGNAL, gracefully shutting down./, error.message) + http_mock.verify + end + end + end + def test_post_invocation_error_with_large_xray_cause large_xray_cause = ('a' * 1024 * 1024)[0..-2] headers = {'Lambda-Runtime-Function-Error-Type' => @error.runtime_error_type,