AWS sdk waiter method always reaches timeout
09:58 13 Feb 2026

I'm implementing a flow for recreating a DynamoDB table with the following steps:

  1. check if the table exists, if not go to step 4
  2. run the delete table command
  3. wait until table is deleted
  4. run the create table command
  5. wait until table is created

Here is simple code of given flow

const recreateTable = async (tableName, tableDefinition) => {
  // step 1
  const command = new ListTablesCommand({});
  const { TableNames } = await dynamoDb.send(command);

  const tableExists = TableNames.includes(tableName);
  
  if (tableExists) {
    // step 2
    const command = new DeleteTableCommand({ TableName: tableName });
    await dynamoDb.send(command);

    // step 3
    await waitUntilTableNotExists({ client: dynamoDb, minDelay: 5, maxDelay: 30, maxWaitTime: 120 }, { TableName: tableName });
  }

  // step 4
  const definition = {
    ...tableDefinition,
    TableName: tableName,
  };
 
  await dynamoDb.send(new CreateTableCommand(definition));
  // step 5
  await waitUntilTableExists({ client: dynamoDb, maxWaitTime: 120 }, { TableName: tableName });

};

The problem is that during step 3, execution doesn't go any further, waiter reaches timeout and throws an error. Increasing timeout duration or changing/adding/removing other params in the waiter doesn't help.
This reproduces both on local hosting and on instance
Here are some additional conclusions:

  1. Table deletion lasts for maybe 10-20 seconds, so there is no obvious reason for waiter method to hold for 2,5,10 minutes and still throw a timeout error
  2. If I call recreateTable once again, the flow will skip steps 2,3 and immediately starts running CreateTableCommand and waitUntilTableExists, which works as expected

I totally understand that this can be solved by simply adding try-catch wrappers and using acustom waiter method with basic polling instead of waitUntilTableNotExists but I'm still keen to understand why this is happening

node.js amazon-web-services amazon-dynamodb aws-sdk