cube-js/cube · error · Error

BigQuery job timeout reached ${this.options.pollTimeout}ms

Error message

BigQuery job timeout reached ${this.options.pollTimeout}ms

What it means

BigQueryDriver.waitForJobResult polls job.getMetadata() on an interval until the job is DONE. If the job does not finish within `options.pollTimeout` milliseconds (default ~10s, configurable via pollTimeout driver option), the driver cancels the job (`await job.cancel()`) and throws this timeout error to avoid hanging forever.

Source

Thrown at packages/cubejs-bigquery-driver/src/BigQueryDriver.ts:477

  }

  protected async waitForJobResult(job: Job, options: any, withResults: boolean) {
    const startedTime = Date.now();

    for (let i = 0; Date.now() - startedTime <= this.options.pollTimeout; i++) {
      const result = await this.awaitForJobStatus(job, options, withResults);
      if (result) {
        return result;
      }

      await pausePromise(
        Math.min(this.options.pollMaxInterval, 200 * i),
      );
    }

    await job.cancel();

    throw new Error(
      `BigQuery job timeout reached ${this.options.pollTimeout}ms`,
    );
  }

  public quoteIdentifier(identifier: string) {
    const nestedFields = identifier.split('.');
    return nestedFields.map(name => {
      if (name.match(/^[a-z0-9_]+$/)) {
        return name;
      }
      return `\`${identifier}\``;
    }).join('.');
  }

  public capabilities(): DriverCapabilities {
    return {
      incrementalSchemaLoading: true,
    };

View on GitHub (pinned to 7d981676b3)

Solutions

  1. Increase the driver option pollTimeout (e.g. pollTimeout: 10 * 60 * 1000) in the BigQueryDriver constructor options
  2. Reduce the amount of data scanned: add partition/time-dimension filters and configure pre-aggregations so queries hit rolled-up tables
  3. Check the BigQuery console for the cancelled job's execution details to find why it was slow
  4. If jobs are legitimately slow, run pre-aggregation builds via a queue with longer timeouts rather than interactive queries

Example fix

// before
const driver = new BigQueryDriver({ projectId, keyFile });
// after
const driver = new BigQueryDriver({ projectId, keyFile, pollTimeout: 10 * 60 * 1000, pollMaxInterval: 5000 });
Defensive patterns

Strategy: retry

Validate before calling

// Estimate scan size before querying (BigQuery dry run)
const [job] = await bigquery.createQueryJob({ query, dryRun: true });
if (Number(job.totalBytesProcessed) > 50e9) {
  throw new Error('Query scans too much data; add pre-aggregations');
}

Try / catch

try {
  await cube.query(query);
} catch (e) {
  if (e.message.includes('BigQuery job timeout reached')) {
    // back off and retry, or build pre-aggregation first
  }
}

Prevention

When it happens

Trigger: Calling query/loadAllFiles when the underlying BigQuery job takes longer than this.options.pollTimeout ms — typically huge scans with no pre-aggregation, or slow on-demand pre-aggregation builds.

Common situations: Large fact tables scanned without partition filters; on-demand pre-aggregations building for minutes; misconfigured pollTimeout left at default for heavy workloads; BigQuery slot contention slowing the job.

Understand the failure class

Related errors


AI-assisted analysis of cube-js/cube@7d981676b3 (2026-09-02). Data as JSON: /api/errors/76b3c55f41531769. Report an issue: GitHub.