Registry / storage / later-queue

later-queue

JSON →
library0.4.0jsnpmunverified

Offline-first client-side task queue for persisting, retrying, and replaying async tasks. Current stable version is 0.4.0. Under active development with frequent bug fixes and feature additions. Key differentiator: designed specifically for React Native and browser environments, leveraging local storage or custom backends for persistence. Heavily typed with TypeScript-first API.

npm install later-queue
INSTALL
IMPORT
SIG · LATER-QUEUE
L
later-queue
storagejavascriptv0.4.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.

Queue
import { Queue } from 'later-queue'
import Queue from 'later-queue'
Queue is a named export, not default.
createQueue
import { createQueue } from 'later-queue'
const createQueue = require('later-queue').createQueue
ESM-only; require() may still work in Node but not recommended.
Task
import type { Task } from 'later-queue'
import { Task } from 'later-queue'
Task is a type (interface); use type import to avoid runtime overhead.

Creates an offline queue that stores tasks in localStorage, adds a fetch task with retry, and starts processing.

import { createQueue } from 'later-queue'; const queue = createQueue({ storage: 'localStorage', maxRetries: 3, retryDelay: 1000, }); queue.add(async () => { const response = await fetch('/api/submit', { method: 'POST', body: JSON.stringify({ data: 'example' }), }); if (!response.ok) throw new Error('Network error'); }); // Queue persists tasks offline and retries on reconnection queue.start();
Debug
Known issues
breakingVersion 0.4.0 changed default storage from 'memory' to 'localStorage'. Existing memory-based queues will lose tasks on page reload.
fix
Explicitly set storage: 'memory' in createQueue options if you need in-memory storage.
affects: >=0.4.0
gotchaTasks are not automatically retried if queue is not started. Call queue.start() after adding tasks.
fix
Always call queue.start() after adding initial tasks, or set autoStart: true in options.
affects: >=0.1.0
deprecatedThe 'retryOn' option has been deprecated in favor of 'retryCondition'. 'retryOn' will be removed in v1.0.
fix
Replace retryOn with retryCondition in queue options.
affects: >=0.3.0
gotchaIf using React Native, the 'localStorage' storage adapter may not be available. You must provide a custom storage adapter compatible with AsyncStorage.
fix
Pass a storage adapter object with getItem, setItem, removeItem methods, e.g., using @react-native-async-storage/async-storage.
affects: >=0.1.0
Errors
Common errors & fixes
TypeError: Cannot read properties of undefined (reading 'getItem')
No storage adapter provided or localStorage not available in the environment (e.g., React Native).
fix
Provide a valid storage adapter in createQueue({ storage: customAdapter }) or use a polyfill for localStorage.
Error: Maximum retry limit reached for task
Task has been retried maxRetries times and still failing; it is moved to failed state.
fix
Check task logic for errors, increase maxRetries, or handle failed tasks via queue.on('taskFailed', callback).
Uncaught (in promise) TypeError: task is not a function
The task passed to queue.add() is not a function; it must be a function returning a Promise.
fix
Wrap your async operation in a function: queue.add(async () => { ... }).
Warning: Queue is not started. Tasks will not be processed.
queue.start() was not called after adding tasks.
fix
Call queue.start() immediately after adding tasks, or set autoStart: true in createQueue options.
Upgrade
Version history
0.4.0latest on npm
Audit
Dependencies
typescriptoptionalPeer dependency for TypeScript type definitions; required for type safety
Agent activity
19 hits · last 30 days
node
18
OpenAI (training)
1
Resources
later-queue — npm install later-queue · libregistry