Registry / devops / firelease

firelease

JSON →
library3.2.1jsnpmunverified

Firelease is a Firebase queue consumer for Node.js with at-least-once and at-most-once semantics, fine-grained concurrency controls, and support for promises and generators (co). Version 3.2.1 is current, actively maintained. Built on top of Nodefire, it offers adjustable lease durations, automatic lease delay for balanced distribution, and preprocessing hooks. It targets Node >=10.0 and is designed for reliable task processing in distributed systems.

npm install firelease
INSTALL
IMPORT
SIG · FIRELEASE
F
firelease
devopsjavascriptv3.2.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.

attachWorker
import { attachWorker } from 'firelease'
const firelease = require('firelease'); firelease.attachWorker(...)
ESM default usage; attachWorker is a named export. CommonJS require is also valid but the named export pattern is preferred.
RETRY
import { RETRY } from 'firelease'
const RETRY = require('firelease').RETRY
RETRY is a named export used as a return value from worker functions.
default
import firelease from 'firelease'
Default export is the module object containing attachWorker and RETRY. This is less common but supported.

Creates a Firebase queue worker with concurrency and lease options, processing tasks with async/await and returning RETRY or undefined.

import { attachWorker, RETRY } from 'firelease'; import { ref } from 'nodefire'; const queueRef = ref('https://my-project.firebaseio.com/queues/myqueue'); attachWorker(queueRef, { maxConcurrent: 5, minLease: '10s', maxLease: '2m', leaseDelay: '0s', maxLeaseDelay: 0, bufferSize: 10, }, async (task) => { console.log('Processing task:', task); if (task.shouldRetry) { return RETRY; } // Delete task for at-most-once: await task.$ref.remove(); return undefined; // removes task from queue });
Debug
Known issues
gotchaThe worker function receives a task object with a special $ref property that is the Nodefire ref of the task. Mutating the task object directly does not update Firebase; use $ref to modify the task in the database.
fix
Access the Firebase ref via task.$ref for any database operations.
affects: >=0.0.0
gotchaThe minLease should equal the maximum expected time a worker will take to handle a task. If the worker takes longer, the lease may expire and another worker can pick up the task, causing duplicate processing.
fix
Set minLease to a value that covers the worst-case task processing time.
affects: >=0.0.0
gotchaThe RETRY return value resets the lease backoff counter, causing immediate retry after the current lease expires. If you need a delay, return a duration or epoch instead.
fix
Use RETRY only for immediate retries; for delayed retries, return a number of milliseconds or an epoch timestamp.
affects: >=0.0.0
gotchaIf using generators, you must set Promise.co to a co-compatible function. Otherwise, generators will not work.
fix
Install the 'co' package and set global.Promise.co = require('co'); before using generator workers.
affects: >=0.0.0
Errors
Common errors & fixes
Cannot find module 'nodefire'
nodefire is a peer dependency not installed automatically.
fix
npm install nodefire
TypeError: task.$ref is not a function
The $ref property is a Nodefire ref, not a function. Calling it as a function causes this error.
fix
Use task.$ref.remove() instead of task.$ref().remove()
Error: The worker returned an invalid value
Worker returned something other than undefined, null, RETRY, a number, or an epoch timestamp.
fix
Ensure worker returns RETRY, undefined, null, a number (ms delay), or an epoch timestamp.
Upgrade
Version history
3.2.1latest on npm
Audit
Dependencies
nodefirerequiredFirelease is built on top of Nodefire for Firebase interaction.
Agent activity
3 hits · last 30 days
node
3
Resources
firelease — npm install firelease · libregistry