Registry / devops / queue-event-emitter

queue-event-emitter

JSON →
library2.1.1jsnpmunverified

A simple EventEmitter that runs each event handler in a queue, ensuring sequential execution of asynchronous handlers. Version 2.1.1 is stable and uses a Promise-based queue with optional concurrency control. Unlike standard EventEmitter (which fires listeners concurrently), QueueEventEmitter guarantees that handlers for the same event type execute one after another (or with a configurable concurrency limit). This prevents race conditions and ensures predictable ordering of async event processing. The package is lightweight, has no dependencies, and is ideal for workflows where order and sequential execution matter (e.g., database writes, API calls). Maintained with infrequent releases.

npm install queue-event-emitter
INSTALL
IMPORT
SIG · QUEUE-EVENT-EMITTE
Q
queue-event-emitter
devopsjavascriptv2.1.1
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.

QueueEventEmitter
const QueueEventEmitter = require('queue-event-emitter')
import QueueEventEmitter from 'queue-event-emitter'
Package provides CommonJS only; ESM import may fail in Node < 13. Use require or dynamic import.
QueueEventEmitter (ESM)
import QueueEventEmitter from 'queue-event-emitter'
import { QueueEventEmitter } from 'queue-event-emitter'
ESM default import works in Node >=13 with --experimental-modules or type: module; named import does NOT exist.
QueueEventEmitter types
import QueueEventEmitter from 'queue-event-emitter'
import { default as QueueEventEmitter } from 'queue-event-emitter'
Package has no TypeScript types; use @types/queue-event-emitter if available, or declare manually.

Shows basic usage: create a queue event emitter, add an async handler, and emit events that run sequentially.

const QueueEventEmitter = require('queue-event-emitter'); const sleep = (time) => new Promise((resolve) => setTimeout(resolve, time)); const emitter = new QueueEventEmitter({ concurrency: 1 }); emitter.on('task', async (data) => { await sleep(1000); console.log('Processed:', data); }); emitter.emit('task', 'A'); emitter.emit('task', 'B'); emitter.emit('task', 'C'); // Output: // Processed: A // Processed: B // Processed: C
Debug
Known issues
deprecatedThe 'newListener' and 'removeListener' events are not emitted when using QueueEventEmitter.
fix
Use standard EventEmitter if you need those events, or implement a workaround.
affects: >=1.0.0
gotchaHandler must return a Promise; if a handler returns a non-Promise value, it may be interpreted as immediate resolution.
fix
Always return a Promise from handlers, or use async functions.
affects: >=2.0.0
gotchaThe 'error' event behavior differs: if no error listener is attached, errors are not thrown globally; they are caught silently.
fix
Always attach an 'error' handler to avoid silent failures.
affects: >=1.0.0
breakingAs of v2.0.0, the 'emit' method no longer returns 'true' or 'false' indicating if there were listeners; it returns undefined.
fix
Replace any code that depends on the return value of emit (e.g., if (emitter.emit(...))). Use 'listenerCount' instead.
affects: >=2.0.0
Errors
Common errors & fixes
TypeError: QueueEventEmitter is not a constructor
Using ESM import { QueueEventEmitter } ... instead of default import or require.
fix
Use const QueueEventEmitter = require('queue-event-emitter'); or import QueueEventEmitter from 'queue-event-emitter';
UnhandledPromiseRejectionWarning: ...
Handler returned a rejected promise and no 'error' listener is attached.
fix
Add emitter.on('error', (err) => console.error(err));
Cannot find module 'queue-event-emitter'
Package not installed or wrong import path.
fix
Run npm install queue-event-emitter, then require correctly.
Upgrade
Version history
2.1.1latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
2 hits · last 30 days
node
2
Resources
queue-event-emitter — npm install queue-event-emitter · libregistry