`Jets.once` sometime stuck with "Init<Seahorse::Client::NetworkingError>" error on AWS lambda

Simple Ruby/Jets function which is running under VPC with all the privileges to access public internet, sometime fails to execute with “InitSeahorse::Client::NetworkingError” . The function do not have any code except to return simple string.

require "bundler/setup"
require "jets"
Jets.once  # runs once in lambda execution context
def index(event:, context:)
    return "Success"
end

This happens intermittently as sometime it runs correctly and sometime it fails with following errors stack

{
“errorMessage”: “execution expired”,
“errorType”: “InitSeahorse::Client::NetworkingError”,
“stackTrace”: [
“/var/lang/lib/ruby/2.5.0/net/http.rb:937:in initialize'", "/var/lang/lib/ruby/2.5.0/net/http.rb:937:inopen’”,
“/var/lang/lib/ruby/2.5.0/net/http.rb:937:in block in connect'", "/var/lang/lib/ruby/2.5.0/timeout.rb:103:intimeout’”,
“/var/lang/lib/ruby/2.5.0/net/http.rb:935:in connect'", "/var/lang/lib/ruby/2.5.0/net/http.rb:920:indo_start’”,
“/var/lang/lib/ruby/2.5.0/net/http.rb:915:in start'", "/var/lang/lib/ruby/2.5.0/delegate.rb:83:inmethod_missing’”,
“/opt/ruby/gems/2.5.0/gems/aws-sdk-core-3.54.1/lib/seahorse/client/net_http/connection_pool.rb:297:in start_session'", "/opt/ruby/gems/2.5.0/gems/aws-sdk-core-3.54.1/lib/seahorse/client/net_http/connection_pool.rb:96:insession_for’”,
“/opt/ruby/gems/2.5.0/gems/aws-sdk-core-3.54.1/lib/seahorse/client/net_http/handler.rb:121:in session'", "/opt/ruby/gems/2.5.0/gems/aws-sdk-core-3.54.1/lib/seahorse/client/net_http/handler.rb:73:intransmit’”,
“/opt/ruby/gems/2.5.0/gems/aws-sdk-core-3.54.1/lib/seahorse/client/net_http/handler.rb:47:in call'", "/opt/ruby/gems/2.5.0/gems/aws-sdk-core-3.54.1/lib/seahorse/client/plugins/content_length.rb:17:incall’”,
“/opt/ruby/gems/2.5.0/gems/aws-sdk-core-3.54.1/lib/aws-sdk-core/xml/error_handler.rb:8:in call'", "/opt/ruby/gems/2.5.0/gems/aws-sdk-core-3.54.1/lib/aws-sdk-core/plugins/signature_v4.rb:66:incall’”,
“/opt/ruby/gems/2.5.0/gems/aws-sdk-core-3.54.1/lib/aws-sdk-core/plugins/transfer_encoding.rb:26:in call'", "/opt/ruby/gems/2.5.0/gems/aws-sdk-core-3.54.1/lib/aws-sdk-core/plugins/helpful_socket_errors.rb:10:incall’”,
“/opt/ruby/gems/2.5.0/gems/aws-sdk-core-3.54.1/lib/aws-sdk-core/plugins/retry_errors.rb:173:in call'", "/opt/ruby/gems/2.5.0/gems/aws-sdk-core-3.54.1/lib/aws-sdk-core/plugins/retry_errors.rb:204:inretry_request’”,
“/opt/ruby/gems/2.5.0/gems/aws-sdk-core-3.54.1/lib/aws-sdk-core/plugins/retry_errors.rb:187:in retry_if_possible'", "/opt/ruby/gems/2.5.0/gems/aws-sdk-core-3.54.1/lib/aws-sdk-core/plugins/retry_errors.rb:175:incall’”,
“/opt/ruby/gems/2.5.0/gems/aws-sdk-core-3.54.1/lib/aws-sdk-core/plugins/retry_errors.rb:204:in retry_request'", "/opt/ruby/gems/2.5.0/gems/aws-sdk-core-3.54.1/lib/aws-sdk-core/plugins/retry_errors.rb:187:inretry_if_possible’”,
“/opt/ruby/gems/2.5.0/gems/aws-sdk-core-3.54.1/lib/aws-sdk-core/plugins/retry_errors.rb:175:in call'", "/opt/ruby/gems/2.5.0/gems/aws-sdk-core-3.54.1/lib/aws-sdk-core/plugins/retry_errors.rb:204:inretry_request’”,
“/opt/ruby/gems/2.5.0/gems/aws-sdk-core-3.54.1/lib/aws-sdk-core/plugins/retry_errors.rb:187:in retry_if_possible'", "/opt/ruby/gems/2.5.0/gems/aws-sdk-core-3.54.1/lib/aws-sdk-core/plugins/retry_errors.rb:175:incall’”,
“/opt/ruby/gems/2.5.0/gems/aws-sdk-core-3.54.1/lib/aws-sdk-core/query/handler.rb:28:in call'", "/opt/ruby/gems/2.5.0/gems/aws-sdk-core-3.54.1/lib/aws-sdk-core/plugins/user_agent.rb:13:incall’”,
“/opt/ruby/gems/2.5.0/gems/aws-sdk-core-3.54.1/lib/aws-sdk-core/plugins/endpoint_pattern.rb:28:in call'", "/opt/ruby/gems/2.5.0/gems/aws-sdk-core-3.54.1/lib/aws-sdk-core/plugins/endpoint_discovery.rb:78:incall’”,
“/opt/ruby/gems/2.5.0/gems/aws-sdk-core-3.54.1/lib/seahorse/client/plugins/endpoint.rb:45:in call'", "/opt/ruby/gems/2.5.0/gems/aws-sdk-core-3.54.1/lib/aws-sdk-core/plugins/param_validator.rb:24:incall’”,
“/opt/ruby/gems/2.5.0/gems/aws-sdk-core-3.54.1/lib/seahorse/client/plugins/raise_response_errors.rb:14:in call'", "/opt/ruby/gems/2.5.0/gems/aws-sdk-core-3.54.1/lib/aws-sdk-core/plugins/jsonvalue_converter.rb:20:incall’”,
“/opt/ruby/gems/2.5.0/gems/aws-sdk-core-3.54.1/lib/aws-sdk-core/plugins/idempotency_token.rb:17:in call'", "/opt/ruby/gems/2.5.0/gems/aws-sdk-core-3.54.1/lib/aws-sdk-core/plugins/param_converter.rb:24:incall’”,
“/opt/ruby/gems/2.5.0/gems/aws-sdk-core-3.54.1/lib/aws-sdk-core/plugins/response_paging.rb:10:in call'", "/opt/ruby/gems/2.5.0/gems/aws-sdk-core-3.54.1/lib/seahorse/client/plugins/response_target.rb:23:incall’”,
“/opt/ruby/gems/2.5.0/gems/aws-sdk-core-3.54.1/lib/seahorse/client/request.rb:70:in send_request'", "/opt/ruby/gems/2.5.0/gems/aws-sdk-core-3.54.1/lib/aws-sdk-sts/client.rb:1329:inget_caller_identity’”,
“/opt/ruby/gems/2.5.0/gems/jets-1.9.9/lib/jets/aws_info.rb:55:in account'", "/opt/ruby/gems/2.5.0/gems/memoist-0.16.0/lib/memoist.rb:170:inaccount’”,
“/opt/ruby/gems/2.5.0/gems/jets-1.9.9/lib/jets/application.rb:197:in default_iam_policy'", "/opt/ruby/gems/2.5.0/gems/jets-1.9.9/lib/jets/application.rb:188:inset_iam_policy’”,
“/opt/ruby/gems/2.5.0/gems/jets-1.9.9/lib/jets/application.rb:23:in configs!'", "/opt/ruby/gems/2.5.0/gems/jets-1.9.9/lib/jets/booter.rb:22:inboot!’”,
“/opt/ruby/gems/2.5.0/gems/jets-1.9.9/lib/jets/core.rb:18:in boot'", "/opt/ruby/gems/2.5.0/gems/jets-1.9.9/lib/jets/core.rb:125:inonce’”,
“/var/task/handlers/jobs/indexer_job.rb:6:in <top (required)>'", "/var/lang/lib/ruby/site_ruby/2.5.0/rubygems/core_ext/kernel_require.rb:54:inrequire’”,
“/var/lang/lib/ruby/site_ruby/2.5.0/rubygems/core_ext/kernel_require.rb:54:in `require’”
]
}

This stack trace was the one that contained enough info for the fix. Sees that it calls aws-sdk-sts/client.rb:1329:inget_caller_identity here.

Handled in #298 Released in v1.9.20