Has the AWS JS SDK REMOVED the ability to control the timeout for dynamodb operations?

1.4k Views Asked by At

While having problems getting setting request timeout on dynamodb/document client (with the v2 SDK, How can the default timeout be set for AWS DocumentClient javascript SDK) I decided to explore switching the the v3 API, since it has certain advantages.

But looking at the full client DynamoDB and more importantly its configuration DynamoDBClientConfig, it seems that there is no way to control the overall request timeout.

Whereas the v2 interface had httpOptions (which seem not to work in the referenced issue) the v3 configuration does not seem to have any control or even any definition for how long an individual request might wait before timing out (and retrying, or whatever).

Does this now have to be implemented with a custom requestHandler? Is there example code for this in node.js?

1

There are 1 best solutions below

0
On

This link about upgrading seems to have an example, in the section about httpOptions. There is an obvious typo in the example there. Looking at the code directly, it is apparent that the agent NEED NOT BE SPECIFIED (there are defaults if the agent is not passed) - so this example is sufficient.

// Use default Https agent, but override the socket timeout
const requestHandler = new NodeHttpHandler({
  connectionTimeout: 30000,
  socketTimeout: 30000,
});

const options = {
  region: AWS_REGION,
  maxAttempts: 2,
  requestHandler, // Use handler with alternate settings for timeouts
};
export const dynamodbClient = new DynamoDB(options);

And this answer - How do I set a timeout for AWS V3 Dynamo Clients - also provides information suggesting how to do this.