Skip to content

Handle Signal Exceptions during Runtime API Http Requests Gracefully and Version Bump to 3.1.3 #50

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jun 11, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions RELEASE.CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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))
Expand Down
2 changes: 2 additions & 0 deletions lib/aws_lambda_ric/lambda_server.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion lib/aws_lambda_ric/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# frozen_string_literal: true

module AwsLambdaRIC
VERSION = '3.1.2'
VERSION = '3.1.3'
end
17 changes: 17 additions & 0 deletions test/unit/lambda_server_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down