Registry / testing / gate-executor

gate-executor

JSON →
library3.3.1jsnpmunverified

Gate Executor is a work queue that supports gating: it can pause processing of the main queue until sub-queues (gates) complete. Current stable version is 3.3.1. It is maintained by the Seneca.js organization and follows a semver release cadence. Key differentiators include the ability to create nested sub-queues forming a tree structure, breadth-first execution order, and efficient timeout handling using a shared setInterval. It ships TypeScript types and requires Node >=12.0.0. Primarily used by Seneca microservice framework for plugin initialization but can be used standalone.

npm install gate-executor
INSTALL
IMPORT
SIG · GATE-EXECUTOR
G
gate-executor
testingjavascriptv3.3.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.

GateExecutor
import GateExecutor from 'gate-executor'
const GateExecutor = require('gate-executor').GateExecutor
Package uses CommonJS default export. With TypeScript 'esModuleInterop' enabled, you can use default import. With older Node.js, use require().
GateExecutor (require)
const GateExecutor = require('gate-executor')
CommonJS require is the traditional way to import this package.
GateExecutor constructor
const ge = GateExecutor()
const ge = new GateExecutor()
GateExecutor is a factory function, not a class. Do not use 'new'.

Demonstrates creating a GateExecutor, adding work items, creating a gate (sub-queue), and starting execution to show breadth-first order.

import GateExecutor from 'gate-executor'; const ge = GateExecutor(); gate.add({ fn: (done) => { console.log('first'); done(); } }); const subge = gate.gate(); gate.add({ fn: (done) => { console.log('second'); done(); } }); subge.add({ fn: (done) => { console.log('third (sub-queue)'); done(); } }); gate.start(() => { console.log('all done'); }); // Output: // first // third (sub-queue) // second // all done
Debug
Known issues
gotchaGateExecutor is a factory function, not a constructor. Using 'new GateExecutor()' will result in an error or unexpected behavior.
fix
Call GateExecutor() without new.
affects: >=1.0.0
gotchaWork items are executed concurrently by default, not sequentially. Gating only ensures sub-queue completion before the next main queue item, but items within a gate run concurrently.
fix
Add work items with a gate to enforce ordering.
affects: >=1.0.0
gotchaIf a work item does not call done() before timeout, it may cause the queue to stall. Default timeout is 30000ms.
fix
Always call done() in work items, or set appropriate timeout via options.
affects: >=1.0.0
Errors
Common errors & fixes
TypeError: GateExecutor is not a constructor
Using 'new GateExecutor()' when GateExecutor is a factory function.
fix
Call GateExecutor() without 'new': const ge = GateExecutor();
Cannot find module 'gate-executor'
Package not installed or import path incorrect.
fix
Run 'npm install gate-executor'. Ensure import/require path is 'gate-executor'.
Upgrade
Version history
3.3.1latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
2 hits · last 30 days
node
2
Resources
gate-executor — npm install gate-executor · libregistry