Skip to content

Commit d6f4cb4

Browse files
M-ElsaeedMohammed Ehab
andauthored
Handle Signal Exceptions during Runtime API Http Requests Gracefully and Version Bump to 3.1.3 (#50)
* Handle Interrupts to the Runtime API Http Requests Gracefully and Version Bump to 3.1.3. * Add Unit Test --------- Co-authored-by: Mohammed Ehab <[email protected]>
1 parent c5cf4de commit d6f4cb4

File tree

4 files changed

+24
-1
lines changed

4 files changed

+24
-1
lines changed

RELEASE.CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
### Jun 10, 2025
2+
`3.1.3`
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))
4+
15
### Jun 6, 2025
26
`3.1.2`
37
- Don't Ignore Custom Formatters. ([#49](https://github.com/aws/aws-lambda-ruby-runtime-interface-client/pull/49))

lib/aws_lambda_ric/lambda_server.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ def next_invocation
3333
"Received #{resp.code} when waiting for next invocation."
3434
)
3535
end
36+
rescue SignalException => sig
37+
raise LambdaErrors::InvocationError.new("Next invocation HTTP request from the runtime interface client was interrupted with a #{sig} SIGNAL, gracefully shutting down.")
3638
rescue LambdaErrors::InvocationError => e
3739
raise e
3840
rescue StandardError => e

lib/aws_lambda_ric/version.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# frozen_string_literal: true
22

33
module AwsLambdaRIC
4-
VERSION = '3.1.2'
4+
VERSION = '3.1.3'
55
end

test/unit/lambda_server_test.rb

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,23 @@ def setup
1515
@under_test = RapidClient.new(@server_address, @mock_user_agent)
1616
end
1717

18+
def test_next_invocation_handles_different_signals
19+
['INT', 'TERM', 'QUIT'].each do |signal|
20+
http_mock = Minitest::Mock.new
21+
http_mock.expect(:read_timeout=, nil, [RapidClient::LONG_TIMEOUT_MS])
22+
http_mock.expect(:start, nil) { raise SignalException.new(signal) }
23+
24+
Net::HTTP.stub :new, http_mock do
25+
error = assert_raises(LambdaErrors::InvocationError) do
26+
@under_test.next_invocation
27+
end
28+
29+
assert_match(/Next invocation HTTP request from the runtime interface client was interrupted with a SIG#{signal} SIGNAL, gracefully shutting down./, error.message)
30+
http_mock.verify
31+
end
32+
end
33+
end
34+
1835
def test_post_invocation_error_with_large_xray_cause
1936
large_xray_cause = ('a' * 1024 * 1024)[0..-2]
2037
headers = {'Lambda-Runtime-Function-Error-Type' => @error.runtime_error_type,

0 commit comments

Comments
 (0)