Registry / messaging / long-task-queue-reader

long-task-queue-reader

JSON →
library0.8.2jsnpmunverified

long-task-queue-reader is a JavaScript library for reading and processing tasks from a long-running task queue, designed to handle large volumes of tasks with backpressure and error handling. Version 0.8.2 is the current stable release, maintained regularly with a focus on robustness and performance. It differs from simple queue libraries by supporting persistent queue backends and providing a reader interface with configurable concurrency, retries, and task acknowledgment. Suitable for Node.js environments with async/await patterns.

npm install long-task-queue-reader
INSTALL
IMPORT
SIG · LONG-TASK-QUEUE-RE
L
long-task-queue-reader
messagingjavascriptv0.8.2
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.

LongTaskQueueReader
import { LongTaskQueueReader } from 'long-task-queue-reader'
const LongTaskQueueReader = require('long-task-queue-reader')
Named export in ES module format
createReader
import { createReader } from 'long-task-queue-reader'
import createReader from 'long-task-queue-reader'
Utility function for creating a reader instance
TaskHandler
import type { TaskHandler } from 'long-task-queue-reader'
TypeScript type for task handler functions

Creates a reader from a Redis queue, processes tasks with acknowledgments, and handles errors.

import { createReader } from 'long-task-queue-reader'; const reader = createReader({ backend: 'redis', redisUrl: process.env.REDIS_URL ?? 'redis://localhost:6379', queueName: 'my-queue', concurrency: 5, }); reader.on('task', async (task) => { console.log('Processing task:', task.id); await processTask(task); reader.acknowledge(task); }); reader.on('error', (err) => { console.error('Reader error:', err); }); await reader.start(); async function processTask(task) { // Simulate processing await new Promise(resolve => setTimeout(resolve, 1000)); }
Debug
Known issues
breakingIn v0.8.0, the 'onTask' event was renamed to 'task'.
fix
Use reader.on('task', handler) instead of reader.on('onTask', handler).
affects: >=0.8.0
gotchaReader does not automatically reconnect if the backend connection drops.
fix
Implement manual reconnection logic or upgrade to a version with auto-reconnect.
affects: <0.9.0
deprecatedThe 'start' method without options is deprecated. Use start({ pollInterval: 1000 }).
fix
Pass an options object to start().
affects: >=0.7.0
gotchaTask handler must call acknowledge() to prevent message redelivery.
fix
Always call reader.acknowledge(task) after successful processing.
affects: >=0.5.0
Errors
Common errors & fixes
Error: backend is not defined
Missing or invalid backend configuration in createReader options.
fix
Provide a valid backend string (e.g., 'redis', 'sqs') in the options object.
TypeError: reader.on is not a function
Using a version that does not expose the reader as an EventEmitter.
fix
Upgrade to v0.6.0+ or use the appropriate API for attaching handlers.
Unhandled rejections from task handler
Task handler is async but does not catch errors properly.
fix
Wrap handler logic in try/catch and emit error event if needed.
Upgrade
Version history
0.8.2latest on npm
Audit
Dependencies
some-queue-backendoptionalBackend dependency for queue storage (e.g., Redis, SQS)
Agent activity
11 hits · last 30 days
node
8
Bingbot
2
OpenAI (training)
1
Resources
long-task-queue-reader — npm install long-task-queue-reader · libregistry