Skip to content

“socketAcquisitionWarningTimeout” option does not work correctly #1528

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
yuji-hatakeyama opened this issue Feb 21, 2025 · 3 comments
Closed
Assignees
Labels
closing-soon This issue will automatically close in 2 days unless further comments are made.

Comments

@yuji-hatakeyama
Copy link
Contributor

yuji-hatakeyama commented Feb 21, 2025

Hi,

I am using "@smithy/node-http-handler" version 4.0.2.

When using Amazon SQS send a message, I encountered the following warning:

WARN @smithy/node-http-handler:WARN - socket usage at capacity=50 and 788 additional requests are enqueued. See https://docs.aws.amazon.com/sdk-for-javascript/v3/developer-guide/node-configuring-maxsockets.html or increase socketAcquisitionWarningTimeout=(millis) in the NodeHttpHandler config.

This warning is logged at the following line:

logger?.warn?.(
`@smithy/node-http-handler:WARN - socket usage at capacity=${socketsInUse} and ${requestsEnqueued} additional requests are enqueued.
See https://docs.aws.amazon.com/sdk-for-javascript/v3/developer-guide/node-configuring-maxsockets.html
or increase socketAcquisitionWarningTimeout=(millis) in the NodeHttpHandler config.`
);

I modified the code and tested it, but setting socketAcquisitionWarningTimeout option did not seem to have any effect.

const client = new SQSClient({
  region: 'ap-northeast-1',
  requestHandler: new NodeHttpHandler({
    socketAcquisitionWarningTimeout: 60_000, # Added
  }),
});

It appears that this issue is caused by socketAcquisitionWarningTimeout not being handled in the configuration setup at:

this.config.socketAcquisitionWarningTimeout ??

It seemed to be caused by not handling “socketAcquisitionWarningTimeout” in the following sections.

const { requestTimeout, connectionTimeout, socketTimeout, httpAgent, httpsAgent } = options || {};
const keepAlive = true;
const maxSockets = 50;
return {
connectionTimeout,
requestTimeout: requestTimeout ?? socketTimeout,
httpAgent: (() => {
if (httpAgent instanceof hAgent || typeof (httpAgent as hAgent)?.destroy === "function") {
return httpAgent as hAgent;
}
return new hAgent({ keepAlive, maxSockets, ...httpAgent });
})(),
httpsAgent: (() => {
if (httpsAgent instanceof hsAgent || typeof (httpsAgent as hsAgent)?.destroy === "function") {
return httpsAgent as hsAgent;
}
return new hsAgent({ keepAlive, maxSockets, ...httpsAgent });
})(),
logger: console,
};
}

I have confirmed that the issue can be resolved by making the following modification:

@@ -122,7 +122,7 @@ or increase socketAcquisitionWarningTimeout=(millis) in the NodeHttpHandler conf
   }

   private resolveDefaultConfig(options?: NodeHttpHandlerOptions | void): ResolvedNodeHttpHandlerConfig {
-    const { requestTimeout, connectionTimeout, socketTimeout, httpAgent, httpsAgent } = options || {};
+    const { requestTimeout, connectionTimeout, socketTimeout, httpAgent, httpsAgent, socketAcquisitionWarningTimeout } = options || {};
     const keepAlive = true;
     const maxSockets = 50;

@@ -142,6 +142,7 @@ or increase socketAcquisitionWarningTimeout=(millis) in the NodeHttpHandler conf
         return new hsAgent({ keepAlive, maxSockets, ...httpsAgent });
       })(),
       logger: console,
+      socketAcquisitionWarningTimeout,
     };
   }

The “socketAcquisitionWarningTimeout” option now works correctly in my environment with this fix.

I am currently working on a pull request to address this issue.

@yuji-hatakeyama
Copy link
Contributor Author

I have created a pull request.
#1529

@kuhe kuhe self-assigned this Feb 21, 2025
@kuhe kuhe added the closing-soon This issue will automatically close in 2 days unless further comments are made. label Feb 24, 2025
@kuhe
Copy link
Contributor

kuhe commented Feb 24, 2025

thanks for your contribution, the fix was published in
https://www.npmjs.com/package/@smithy/node-http-handler/v/4.0.3

@yuji-hatakeyama
Copy link
Contributor Author

@kuhe
Thank you for the speedy confirmation and publish!

@kuhe kuhe closed this as completed Feb 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
closing-soon This issue will automatically close in 2 days unless further comments are made.
Projects
None yet
Development

No branches or pull requests

2 participants