Skip to content

Proxy Support for APIGatewayClient Broken in 3.502.0 -> 3.513.0 #5794

Closed
@m3h

Description

@m3h

Checkboxes for prior research

Describe the bug

GetApiKeysCommand fails when using a proxy with the following error:

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

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

Node.js v20.10.0

SDK version number

@aws-sdk/[email protected] - @aws-sdk/[email protected]

Which JavaScript Runtime is this issue in?

Node.js

Details of the browser/Node.js/ReactNative version

v20.10.0

Reproduction Steps

Run the following script, using @aws-sdk/client-api-gateway versions 3.502.0 to 3.513.0, replacing the proxy ("http://127.0.0.1:3128") with an HTTPS-capable proxy. Ensure outbound traffic flows through proxy, and that no DNS queries are made from the sdk (DNS should be handled by proxy). My environment is behind a corporate VPN that blocks general internet access, except via a proxy.

const { NodeHttpHandler } = require('@smithy/node-http-handler');
const { HttpsProxyAgent } = require('hpagent');
const { APIGatewayClient, GetApiKeysCommand } = require('@aws-sdk/client-api-gateway');

const agent = new HttpsProxyAgent({ proxy: "http://127.0.0.1:3128" });
const apiGatewayClient = new APIGatewayClient({
        requestHandler: new NodeHttpHandler({
          httpAgent: agent,
          httpsAgent: agent,
        }),
});

const getApiKeysCmd = new GetApiKeysCommand({
        limit: 2,
        includeValues: true,
});

async function main() {
        const apiGatewayKeysResponse = await apiGatewayClient.send(getApiKeysCmd);
        console.log(apiGatewayKeysResponse);
}

main()

Observed Behavior

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

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

Node.js v20.10.0

Expected Behavior

I expected the code snippet to print a list of API keys.

Possible Solution

Possibly related to the lazy load STS & SSO clients in credential providers feature, introduced in v3.502.0: https://github.com/aws/aws-sdk-js-v3/releases/tag/v3.502.0

Additional Information/Context

Any version below 3.502.0 seems to work.

Output of npm list:

└─➜ npm list
proxy-issues@ /.../proxy-issues
├── @aws-sdk/[email protected]
├── @smithy/[email protected]
└── [email protected]

Output of npm --version:

└─➜ npm --version
10.2.3

Metadata

Metadata

Assignees

Labels

bugThis issue is a bug.p2This is a standard priority issuepending-releaseThis issue will be fixed by an approved PR that hasn't been released yet.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions