
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
A BullMQ alternative using Bun's Worker API instead of Redis. bunMQ provides a simple, fast, and lightweight job queue system for background processing.
bun add bunmq
import { Queue } from 'bunmq';
// Create a queue with 2 workers
const queue = new Queue(2);
// Define a function to process
function sendEmail(to: string, subject: string, body: string) {
console.log(`Sending email to ${to}: ${subject}`);
return Promise.resolve({ success: true });
}
// Enqueue a job
const jobId = queue.enqueue(
sendEmail,
{
delay: 1000, // Wait 1 second before processing
attempts: 3, // Retry up to 3 times
backoff: {
type: 'exponential',
delay: 1000
}
},
'user@example.com', // to parameter
'Welcome!', // subject parameter
'Welcome message' // body parameter
);
console.log('Job enqueued:', jobId);
new Queue(workerCount?: number)
workerCount: Number of worker threads (default: 1)enqueue<T>(fn: T, options?: JobOptions, ...params: Parameters<T>): stringEnqueue a function to be executed in a worker thread.
Parameters:
fn: Function to executeoptions: Job configuration options...params: Parameters to pass to the functionReturns: Job ID string
getJob(jobId: string): JobData | undefinedGet job information by ID.
getJobs(status?: JobStatus): JobData[]Get all jobs, optionally filtered by status.
getStats(): QueueStatsGet queue statistics.
close(): Promise<void>Gracefully close the queue and terminate all workers.
onJobStart(handler: (job: JobData) => void): voidCalled when a job starts processing.
onJobComplete(handler: (job: JobData, result: any) => void): voidCalled when a job completes successfully.
onJobError(handler: (job: JobData, error: string) => void): voidCalled when a job encounters an error.
onJobRetry(handler: (job: JobData, attempt: number) => void): voidCalled when a job is being retried.
onJobFailed(handler: (job: JobData, error: string) => void): voidCalled when a job fails after all retry attempts.
onQueueEmpty(handler: () => void): voidCalled when the queue becomes empty (no waiting or active jobs).
onQueueError(handler: (error: Error) => void): voidCalled when a queue-level error occurs.
setEvents(events: QueueEvents): voidSet multiple event handlers at once.
interface JobOptions {
delay?: number; // Delay before processing (ms)
attempts?: number; // Number of retry attempts
backoff?: { // Retry backoff strategy
type: 'fixed' | 'exponential';
delay: number;
};
removeOnComplete?: number; // Keep N completed jobs
removeOnFail?: number; // Keep N failed jobs
priority?: number; // Job priority (higher = more priority)
}
interface JobData {
id: string; // Unique job ID
functionName: string; // Function name
params: any[]; // Function parameters
options: JobOptions; // Job options
createdAt: number; // Creation timestamp
attempts: number; // Current attempt number
status: 'waiting' | 'active' | 'completed' | 'failed' | 'delayed';
}
import { Queue } from 'bunmq';
const queue = new Queue();
function processData(data: string) {
console.log('Processing:', data);
return `Processed: ${data}`;
}
// Enqueue a job
const jobId = queue.enqueue(processData, {}, 'Hello World');
function unreliableTask() {
if (Math.random() < 0.5) {
throw new Error('Random failure');
}
return 'Success!';
}
const jobId = queue.enqueue(
unreliableTask,
{
attempts: 5,
backoff: { type: 'exponential', delay: 1000 }
}
);
function sendReminder() {
console.log('Sending reminder email');
}
// Send reminder in 1 hour
queue.enqueue(
sendReminder,
{ delay: 60 * 60 * 1000 }
);
// Get queue statistics
const stats = queue.getStats();
console.log('Queue stats:', stats);
// { waiting: 2, active: 1, completed: 5, failed: 0, total: 8 }
// Get specific job
const job = queue.getJob('job_123');
console.log('Job status:', job?.status);
// Get all completed jobs
const completed = queue.getCompletedJobs();
console.log('Completed jobs:', completed.length);
const queue = new Queue(2);
// Set up event handlers
queue.onJobStart((job) => {
console.log(`Job started: ${job.id}`);
});
queue.onJobComplete((job, result) => {
console.log(`Job completed: ${job.id} with result:`, result);
});
queue.onJobError((job, error) => {
console.log(`Job error: ${job.id} - ${error}`);
});
queue.onJobRetry((job, attempt) => {
console.log(`Job retry: ${job.id} (attempt ${attempt})`);
});
queue.onJobFailed((job, error) => {
console.log(`Job failed: ${job.id} after all retries`);
});
queue.onQueueEmpty(() => {
console.log('All jobs processed!');
});
// Or set multiple events at once
queue.setEvents({
onJobStart: (job) => console.log(`Started: ${job.id}`),
onJobComplete: (job, result) => console.log(`Completed: ${job.id}`),
onQueueEmpty: () => console.log('Queue empty!')
});
bunMQ leverages Bun's optimized Worker API and includes several performance optimizations:
postMessage with fast paths for strings and simple objects| Feature | bunMQ | BullMQ |
|---|---|---|
| Dependencies | None (Bun only) | Redis required |
| Setup | Instant | Redis server needed |
| Performance | Very fast | Fast (with Redis) |
| Persistence | In-memory | Redis-backed |
| Clustering | Single process | Multi-process with Redis |
# Run the example
bun run example.ts
MIT
FAQs
Unknown package
We found that bunmq demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.