Registry / storage / queue-that

queue-that

JSON →
library2.9.0jsnpmunverified

A browser-based queue managed in localStorage for batching and deferring async tasks (e.g., XHR requests) until just before page unload. Current stable version 2.9.0, released as needed on GitHub. It batches tasks into 100ms groups, supports cross-tab coordination (only one active queue per label), exponential backoff on failure, configurable batch size and timeout, and falls back to an in-memory variable if localStorage throws. Distinct from generic queue libraries by its localStorage persistence and unload-safe flushing.

npm install queue-that
INSTALL
IMPORT
SIG · QUEUE-THAT
Q
queue-that
storagejavascriptv2.9.0
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

queueThat
✓ import queueThat from 'queue-that'
✗ const queueThat = require('queue-that')
Package is CJS-only; import works only with bundlers that interop with CJS, or use require() in Node/Browserify.
queueThat
✓ const queueThat = require('queue-that')
The default export is a factory function that expects an options object. Do not destructure named exports; there are none.
queueThat
✓ const queueThat = require('queue-that'); const q = queueThat({ process: (batch, done) => done() })
✗ const q = require('queue-that')({ label: 'x' })
The function must be called with options; if called directly (without assigning), the returned function is lost.

Creates a queue with a process function and queues a single task.

const queueThat = require('queue-that'); const q = queueThat({ label: 'MyQueue', process: (batch, done) => { // Send batch to server console.log('Processing batch:', batch); done(); }, batchSize: 10 }); // Queue a task const task = { type: 'click', data: { x: 100, y: 200 } }; q(task);
Debug
Known issues
gotchalocalStorage may throw in private browsing mode or be unavailable; queue-that falls back to an in-memory variable, which is not persistent between page loads.
fix
Wrap queueThat initialization in try/catch or use a polyfill for localStorage if you need guaranteed persistence.
affects: >=1.0.0
gotchaThe process function must call the done callback; if not called, the queue will hang and never process further batches after the 2-second timeout and backoff.
fix
Always call done() in your process implementation, including on error (with an error argument to trigger backoff).
affects: >=1.0.0
gotchaTasks are batched into 100ms groups by default; if you queue a task and immediately queue another within 100ms, they may end up in the same batch. To disable batching set batchSize to Infinity.
fix
Adjust batchSize or queueGroupTime to control batching behaviour.
affects: >=1.0.0
breakingIn version 2.0.0, the API changed from requiring 'queue-that' directly to a factory function pattern. Old code using the module as a constructor will break.
fix
Upgrade to v2 and call require('queue-that')() with options object.
affects: ~1.0.0
Errors
Common errors & fixes
TypeError: queueThat is not a function
Using import syntax with a CJS-only package without a bundler that handles CJS interop.
fix
Use const queueThat = require('queue-that'); instead of import queueThat from 'queue-that'.
Error: label 'Queue That' already in use
Two queues with the same label interfere because they share localStorage key.
fix
Use distinct label strings for logically separate queues.
RangeError: Maximum call stack size exceeded
The queue triggers recursive processing when process() calls done() synchronously and the queue is full.
fix
Ensure process() calls done() asynchronously (e.g., setTimeout 0) to avoid stack overflow.
Upgrade
Version history
2.9.0latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
22 hits · last 30 days
node
18
Amazon
1
OpenAI (training)
1
Resources
queue-that — npm install queue-that · libregistry