Getting Started

Configuration

Configure the Queuedash SDK for your workflow.

Most teams keep the defaults. Adjust batching and retries only when you need finer control.

Minimal setup

import { Queuedash } from "@queuedash/sdk";
 
const qd = new Queuedash({
  apiKey: process.env.QUEUEDASH_API_KEY,
});

Common options

const qd = new Queuedash({
  apiKey: process.env.QUEUEDASH_API_KEY,
  batchSize: 100, // default 50
  flushInterval: 200, // default 100ms
  maxRetries: 3, // default 5
  requestTimeout: 20000, // default 30000
  onError: (error) => {
    // Send to your error tracking
    Sentry.captureException(error);
  },
});
OptionDefaultNotes
apiKey-Required. The constructor throws without it.
baseUrlhttps://sync.queuedash.com when NODE_ENV is production, otherwise http://localhost:4002Where batches are sent.
batchSize50Jobs per batch; increase for high throughput.
flushInterval100msSend cadence; reduce for lower latency.
maxRetries5Retry attempts before a batch is dropped.
requestTimeout30000msHTTP timeout, including reading the response.
maxQueueSize10000Jobs held in memory; when full, the oldest is dropped.
onError-Called when a batch is dropped, when reporting a removed job fails, and when a BullMQ queue can't be attached.

Batching & resilience

  • Batches flush when hitting batchSize or flushInterval, whichever comes first.
  • Batches over 4.5 MB of JSON are split before sending.
  • A batch that fails to send is retried after 1, 2, 4, 8, then 16 seconds (each wait doubles, up to 30 seconds). Jobs that arrive in the meantime go with the retry. After maxRetries retries the batch is dropped and onError is called, about 31 seconds after the first failure with the defaults.
  • After 10 failed sends in a row, the SDK stops sending for 60 seconds, then resumes. Jobs it hears about during those 60 seconds are dropped.

These describe SDK 2.0.1 and later.

Shutdown

On SIGTERM or SIGINT, the SDK flushes what it holds and then exits the process with code 0, which can cut short your own shutdown handlers. You can also stop it yourself:

await qd.stop();

stop() doesn't wait out a pending retry: it makes one final attempt, and if that fails the jobs go to onError.