Skip to content

Conversation

@trivikr
Copy link
Contributor

@trivikr trivikr commented Jun 13, 2025

Issue #, if available:
Internal JS-5916

Description of changes:
Treat Node.js network errors as transient

Verified in local testing by disabling WiFi that 3 attempts are made

Test code

import { STS } from "@aws-sdk/client-sts";
new STS().getCallerIdentity();

Before

$ node:internal/process/promises:394
    triggerUncaughtException(err, true /* fromPromise */);
    ^

Error: getaddrinfo ENOTFOUND sts.us-west-2.amazonaws.com
    at GetAddrInfoReqWrap.onlookupall [as oncomplete] (node:dns:122:26) {
  errno: -3008,
  code: 'ENOTFOUND',
  syscall: 'getaddrinfo',
  hostname: 'sts.us-west-2.amazonaws.com',
  '$metadata': { attempts: 1, totalRetryDelay: 0 }
}

Node.js v22.15.1

After

$ grep NODEJS_NETWORK_ERROR_CODES node_modules/@smithy/service-error-classification/dist-cjs/index.js

var NODEJS_NETWORK_ERROR_CODES = ["ENOTFOUND"];
var isTransientError = /* @__PURE__ */ __name((error, depth = 0) => isClockSkewCorrectedError(error) || TRANSIENT_ERROR_CODES.includes(error.name) || NODEJS_TIMEOUT_ERROR_CODES.includes(error?.code || "") || NODEJS_NETWORK_ERROR_CODES.includes(error?.code || "") || TRANSIENT_ERROR_STATUS_CODES.includes(error.$metadata?.httpStatusCode || 0) || isBrowserNetworkError(error) || error.cause !== void 0 && depth <= 10 && isTransientError(error.cause, depth + 1), "isTransientError");

$ node test.mjs
node:internal/process/promises:394
    triggerUncaughtException(err, true /* fromPromise */);
    ^

Error: getaddrinfo ENOTFOUND sts.us-west-2.amazonaws.com
    at GetAddrInfoReqWrap.onlookupall [as oncomplete] (node:dns:122:26) {
  errno: -3008,
  code: 'ENOTFOUND',
  syscall: 'getaddrinfo',
  hostname: 'sts.us-west-2.amazonaws.com',
  '$metadata': { attempts: 3, totalRetryDelay: 226 }
}

Node.js v22.15.1

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@trivikr trivikr marked this pull request as ready for review June 13, 2025 17:15
@trivikr trivikr requested a review from a team as a code owner June 13, 2025 17:15
@trivikr trivikr merged commit c8d5bb2 into main Jun 13, 2025
11 checks passed
@kuhe kuhe deleted the add-node-network-error branch June 16, 2025 14:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants