npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

athena-query-execution-waiter

v0.5.3

Published

A small library that waits for an AWS Athena query execution to complete. It polls the Athena API until the execution reaches a terminal state: SUCCEEDED, FAILED, or CANCELLED.

Readme

Athena Query Execution Waiter

npm version License

A small library that waits for an AWS Athena query execution to complete. It polls the Athena API until the execution reaches a terminal state: SUCCEEDED, FAILED, or CANCELLED.

Features

  • Polls GetQueryExecution until the run finishes or an overall wall-clock timeout is exceeded (separate from polling interval).
  • Configurable overall timeout and poll spacing via wait() options; default overall cap is DEFAULT_TIMEOUT_MS (2 minutes).
  • Typed errors: AthenaQueryExecutionWaiterTimeoutError, AthenaQueryExecutionWaiterStateError (failed or cancelled runs), AthenaQueryExecutionWaiterMissingStateError, AthenaQueryExecutionWaiterUnsupportedStateError.
  • Built for AWS SDK for JavaScript v3 (@aws-sdk/client-athena).

Installation

@aws-sdk/client-athena is a normal dependency of this package: installing athena-query-execution-waiter pulls in a compatible AWS SDK v3 Athena client. If your app also depends on @aws-sdk/client-athena, npm/yarn will dedupe when versions are compatible; otherwise you may have two copies under different semver ranges.

yarn:

yarn add athena-query-execution-waiter

npm:

npm install athena-query-execution-waiter

Requirements

  • Node.js >= 20.0.0
  • @aws-sdk/client-athena — declared in this package’s package.json under dependencies (AWS SDK v3; version range is maintained there).

Usage

import { AthenaClient } from '@aws-sdk/client-athena';
import {
  AthenaQueryExecutionWaiter,
  DEFAULT_TIMEOUT_MS,
  AthenaQueryExecutionWaiterTimeoutError,
  AthenaQueryExecutionWaiterStateError,
} from 'athena-query-execution-waiter';

const client = new AthenaClient({ region: 'us-east-1' });
const waiter = new AthenaQueryExecutionWaiter(client);

// After StartQueryExecution, wait until the execution completes
const queryExecutionId = 'your-query-execution-id';

try {
  const state = await waiter.wait(queryExecutionId);
  console.log('Query completed:', state); // "SUCCEEDED"
} catch (err) {
  if (err instanceof AthenaQueryExecutionWaiterTimeoutError) {
    console.error('Query timed out');
  }
  if (err instanceof AthenaQueryExecutionWaiterStateError) {
    console.error('Query failed or cancelled:', err.state, err.reason);
  }
  throw err;
}

Overall timeout vs polling interval

| | Meaning | |---|--------| | waitOptions.timeoutMs / DEFAULT_TIMEOUT_MS | Overall wall-clock limit from when wait() starts until SUCCEEDED, FAILED, or CANCELLED (or this cap is exceeded). Omit timeoutMs to use DEFAULT_TIMEOUT_MS. This is not how often Athena is polled. | | pollIntervalMs | Delay between GetQueryExecution calls. Independent of the overall timeout; a long poll interval still respects waitOptions.timeoutMs / DEFAULT_TIMEOUT_MS. |

Long-running jobs should pass a higher timeoutMs when needed:

const state = await waiter.wait(queryExecutionId, {
  timeoutMs: 15 * 60_000, // 15 minutes overall
});

Default polling interval is 1 second. Increase it to reduce API calls (constructor or per wait()):

const waiter = new AthenaQueryExecutionWaiter(client, { pollIntervalMs: 5000 });

const state = await waiter.wait(queryExecutionId, {
  timeoutMs: 60_000,
  pollIntervalMs: 3000,
});

Options

AthenaQueryExecutionWaiterOptions (constructor)

Passed to new AthenaQueryExecutionWaiter(client, options?).

| Option | Type | Description | |--------|------|-------------| | pollIntervalMs | number (optional) | Default milliseconds between GetQueryExecution calls when wait() omits pollIntervalMs. Default: 1000. |

AthenaQueryExecutionWaitOptions (wait())

Passed to wait(queryExecutionId, waitOptions?).

| Option | Type | Description | |--------|------|-------------| | timeoutMs | number (optional) | Overall wall-clock timeout in ms from the start of wait() until a terminal state. Default: DEFAULT_TIMEOUT_MS (2 minutes). | | pollIntervalMs | number (optional) | Milliseconds between polls for this call. Default: constructor’s pollIntervalMs or 1000. |

API reference

AthenaQueryExecutionWaiter

  • Constructor: new AthenaQueryExecutionWaiter(client: AthenaClient, options?: AthenaQueryExecutionWaiterOptions)
  • wait(queryExecutionId: string, waitOptions?: AthenaQueryExecutionWaitOptions): Promise<QueryExecutionState>
    • Returns SUCCEEDED on success.
    • Throws AthenaQueryExecutionWaiterTimeoutError if overall wait exceeds the effective timeout.
    • Throws AthenaQueryExecutionWaiterStateError when the state is FAILED or CANCELLED.
    • Throws AthenaQueryExecutionWaiterMissingStateError when QueryExecution, Status, or State is missing from the API response (fail-fast; no polling until timeout).
    • Throws AthenaQueryExecutionWaiterUnsupportedStateError when State is present but not a known QueryExecutionState (e.g. a future Athena enum value).

Constants

  • DEFAULT_TIMEOUT_MS — Default overall wait cap in milliseconds (2 minutes) when waitOptions.timeoutMs is omitted. Safe to import for your own guards or logging.

Errors

  • AthenaQueryExecutionWaiterError — Base class for waiter errors.
  • AthenaQueryExecutionWaiterTimeoutError — Overall elapsed time since wait() started exceeded waitOptions.timeoutMs or DEFAULT_TIMEOUT_MS. Constructor: (elapsedTime: number).
  • AthenaQueryExecutionWaiterStateError — Query ended in FAILED or CANCELLED. Properties: state, reason. Constructor: (state: QueryExecutionState, reason?: string).
  • AthenaQueryExecutionWaiterMissingStateErrorGetQueryExecution response is missing QueryExecution, Status, or State. Property: detail. Fails on the first poll.
  • AthenaQueryExecutionWaiterUnsupportedStateErrorState is not one of the known values (QUEUED, RUNNING, SUCCEEDED, FAILED, CANCELLED). Property: state. Fails on the first poll.

License

This project is licensed under the Apache-2.0 License.