Registry / devops / async-queue-runner

async-queue-runner

JSON →
library1.1.0jsnpmunverified

A TypeScript library to run extendable async queues with branching, context mutation, and optional locking scopes. Version 1.1.0 is the latest stable release. It differentiates itself by supporting action branching, runtime context extension, queue locking to prevent concurrent execution of same-scope actions across queues, and error handling per action with recovery. It provides both a QueueRunner (manages multiple queues with shared locking) and a standalone AsyncQueue. The library is ESM-only and ships with TypeScript types.

npm install async-queue-runner
INSTALL
IMPORT
SIG · ASYNC-QUEUE-RUNNER
A
async-queue-runner
devopsjavascriptv1.1.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.

Action
import { Action } from 'async-queue-runner'
const Action = require('async-queue-runner').Action
ESM-only. CommonJS require will break in runtime.
QueueRunner
import { QueueRunner } from 'async-queue-runner'
import QueueRunner from 'async-queue-runner'
Named export, not default. Also available: AsyncQueue, lockingClassFactory, util.
lockingClassFactory
import { lockingClassFactory } from 'async-queue-runner'
Factory function to create an Action class with a given lock scope. The resulting class still needs to be used with a LockManager or QueueRunner.

Creates a queue that increments a value twice, stops if value >= 3, then adds another increment (never executed because queue aborted).

import { Action, QueueRunner, QueueContext } from 'async-queue-runner'; type Ctx = { value: number }; class Increment extends Action<Ctx> { async execute({ value, extend }: Ctx & QueueContext): Promise<void> { extend({ value: value + 1 }); } } class StopIfTooHigh extends Action<Ctx> { async execute({ value, abort }: Ctx & QueueContext): Promise<void> { if (value >= 3) abort(); } } const runner = new QueueRunner(); runner.add([Increment, Increment, StopIfTooHigh, Increment], { value: 0 }); runner.run();
Debug
Known issues
gotchaUsing require() instead of ESM import will cause 'exports is not defined' error.
fix
Use import syntax or set type: 'module' in package.json.
affects: >=1.0
gotchaAction classes passed as constructor references are instantiated with no arguments. To pass constructor options, pass an instance instead.
fix
Use runner.add([new MyAction(options)]) instead of runner.add([MyAction]).
affects: >=1.0
gotchaAborting via context.abort() clears the remaining queue but does not prevent current action from finishing. Subsequent actions after abort are skipped.
fix
Use abort() early in execute() to stop future actions.
affects: >=1.0
gotchaLock scopes must be non-empty strings. Passing an empty string throws an error.
fix
Provide a non-empty string to lockingClassFactory or any lock-related API.
affects: >=1.0
gotchaThe util.if and util.valid functions require a predicate returning boolean. Predicate errors are not caught; they propagate as unhandled rejections.
fix
Wrap predicate logic in try-catch or ensure it never throws.
affects: >=1.0
Errors
Common errors & fixes
TypeError: Class constructor Action cannot be invoked without 'new'
Attempting to call Action() as a function instead of extending it.
fix
class MyAction extends Action<Ctx> { ... }
Error: Lock scope cannot be empty
Passed an empty string to lockingClassFactory or LockManager.
fix
Ensure lock scope is a non-empty string, e.g., 'browser'.
TypeError: queueRunner.add is not a function
Using a QueueRunner instance that was not properly imported or instantiated.
fix
import { QueueRunner } from 'async-queue-runner'; const runner = new QueueRunner();
TypeError: context.abort is not a function
The action's execute method signature does not include QueueContext.
fix
Ensure execute receives context with type `Ctx & QueueContext` or includes abort in destructuring.
Upgrade
Version history
1.1.0latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
10 hits · last 30 days
node
8
OpenAI (training)
2
Resources
async-queue-runner — npm install async-queue-runner · libregistry