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.
ModestQueue
✓ import { ModestQueue } from 'modest-queue'
✗ const ModestQueue = require('modest-queue')
ESM only; named export. TypeScript types included. You must import 'reflect-metadata' before use.
Default export
✓ import { ModestQueue } from 'modest-queue'
✗ import ModestQueue from 'modest-queue'
No default export; use named import.
Type imports
✓ import { ModestQueue } from 'modest-queue'
✗ import { ModestQueue } from 'modest-queue/dist'
Types are bundled in main entry, no need to import from dist.
Shows basic initialization, message publishing (simple & delayed with priority), polling, and success acknowledgment.
import 'reflect-metadata';
import { ModestQueue } from 'modest-queue';
async function main() {
const queue = new ModestQueue({
queueName: 'tasks',
connectionString: process.env.REDIS_URL ?? 'redis://localhost:6379',
visibilityTimeout: 30, // seconds
maxRetries: 3,
});
await queue.initialize();
// Publish a simple message
await queue.publish('hello world');
// Publish with delay (1 second) and priority
await queue.publish('delayed message', { delay: 1000, priority: 10 });
// Poll for a message
const message = await queue.pollForMessage();
if (message) {
console.log('Received:', message.body);
// Process and acknowledge
await queue.messageSucceeded(message);
}
await queue.dispose();
}
main().catch(console.error);
Errors
Common errors & fixes
TypeError: Class constructor ModestQueue cannot be invoked without 'new'
Using CommonJS require instead of ES6 import.
fixUse import { ModestQueue } from 'modest-queue' and ensure 'type':'module' in package.json or use .mjs extension. Error: reflect-metadata shim is required when using class-transformer
Missing import 'reflect-metadata' at entry point.
fixAdd 'import "reflect-metadata"' at the top of your application entry file before using ModestQueue.
ERR unknown command 'ZPOPMIN'
Redis server version is below 5.0.0.
fixUpgrade Redis to version 5.0.0 or higher.
ioredis: Unhandled error event: ReplyError: MOVED 1234
Connecting to a Redis cluster with unsupported configuration (e.g., non-clustered connection).
fixUse a clustered ioredis instance with proper cluster options.
TypeError: Cannot read properties of undefined (reading 'options')
Missing or malformed ModestQueue constructor options.
fixProvide a valid config object with 'queueName' and either 'connectionString' or 'redisConnection'.
Audit
Dependencies
ioredisoptionalUnderlying Redis client for all queue operations. Required but abstracted; you can pass your own connection string or ioredis instance.
reflect-metadataoptionalRequired by class-transformer for decorator support. Must be imported at application entry point before using ModestQueue.
class-transformeroptionalUsed internally for message serialization/deserialization. Not required if you use simple strings/JSON.