Open trivikr opened 4 days ago
The SDK does not retry if network is unavailable
All
Node.js
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();
When run after disabling the network, the $metadata indicates retry attempts were not made
$metadata
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 } }
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 } }
Process ENOTFOUND from Node.js as a retryable error?
ENOTFOUND
https://github.com/aws/aws-sdk-js/blob/f430ca2d083e6d3cb94943081bb40ef33d6a78f4/lib/event_listeners.js#L601-L620
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.
A response can be retryable based on various attributes:
Checkboxes for prior research
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
Disable the network, and run the test code. In the output, you can see that three retries were made
An equivalent code in v3
Observed Behavior
When run after disabling the network, the
$metadata
indicates retry attempts were not madeExpected Behavior
The error should still be thrown since network is disabled, but after four attempts (three retries) as follows
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