aws-sdk-js-v3
aws-sdk-js-v3 copied to clipboard
The SDK does not retry if network is unavailable
Checkboxes for prior research
- [X] I've gone through Developer Guide and API reference
- [X] I've checked AWS Forums and StackOverflow.
- [X] I've searched for previous similar issues and didn't find any solution.
Describe the bug
The SDK does not retry if network is unavailable
SDK version number
All
Which JavaScript Runtime is this issue in?
Node.js
Details of the browser/Node.js/ReactNative version
All
Reproduction Steps
The v2 source code for comparison
import AWS from "aws-sdk";
const client = new AWS.S3({ logger: console });
try {
await client.listBuckets().promise();
} catch (error) {}
Disable the network, and run the test code. In the output, you can see that three retries were made
[AWS s3 undefined 0.25s 3 retries] listBuckets({})
An equivalent code in v3
import { S3 } from "@aws-sdk/client-s3";
const client = new S3();
await client.listBuckets();
Observed Behavior
When run after disabling the network, the $metadata
indicates retry attempts were not made
node:internal/modules/run_main:129
triggerUncaughtException(
^
Error: getaddrinfo ENOTFOUND s3.us-west-2.amazonaws.com
at GetAddrInfoReqWrap.onlookupall [as oncomplete] (node:dns:120:26) {
errno: -3008,
code: 'ENOTFOUND',
syscall: 'getaddrinfo',
hostname: 's3.us-west-2.amazonaws.com',
'$metadata': { attempts: 1, totalRetryDelay: 0 }
}
Expected Behavior
The error should still be thrown since network is disabled, but after four attempts (three retries) as follows
node:internal/modules/run_main:129
triggerUncaughtException(
^
Error: getaddrinfo ENOTFOUND s3.us-west-2.amazonaws.com
at GetAddrInfoReqWrap.onlookupall [as oncomplete] (node:dns:120:26) {
errno: -3008,
code: 'ENOTFOUND',
syscall: 'getaddrinfo',
hostname: 's3.us-west-2.amazonaws.com',
'$metadata': { attempts: 4, totalRetryDelay: 357 }
}
Possible Solution
Process ENOTFOUND
from Node.js as a retryable error?
https://github.com/aws/aws-sdk-js/blob/f430ca2d083e6d3cb94943081bb40ef33d6a78f4/lib/event_listeners.js#L601-L620
Additional Information/Context
The internal specification for retries says
A response can be retryable based on various attributes:
- Connection errors, defined as any error received by the SDK in which we were unable to receive an HTTP response from the service.