bunqueue 2.8.11 → 2.8.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -127,6 +127,8 @@ export declare class Worker<T = unknown, R = unknown> extends EventEmitter {
|
|
|
127
127
|
private tryProcess;
|
|
128
128
|
private registerPulledJobs;
|
|
129
129
|
private getBufferedJob;
|
|
130
|
+
/** Put an item back at the front of the pending buffer (Issue #96). */
|
|
131
|
+
private requeueItem;
|
|
130
132
|
/**
|
|
131
133
|
* Get the next buffered job eligible for processing.
|
|
132
134
|
* When group concurrency is enabled, skips jobs whose group is at capacity
|
|
@@ -516,6 +516,19 @@ export class Worker extends EventEmitter {
|
|
|
516
516
|
}
|
|
517
517
|
}
|
|
518
518
|
if (item) {
|
|
519
|
+
// Issue #96: re-check the concurrency gate before starting. poll()
|
|
520
|
+
// checked it, but `await doPullBatch()` above — or a setImmediate path
|
|
521
|
+
// that bypasses poll() — may have filled the slots since. This check is
|
|
522
|
+
// atomic with startJob()'s activeJobs++ (no await between here and the
|
|
523
|
+
// increment), so it cannot overshoot. If full, requeue the job (we still
|
|
524
|
+
// own it via pulledJobIds/jobTokens) and let a freed slot pick it up.
|
|
525
|
+
if (this.activeJobs >= this.opts.concurrency) {
|
|
526
|
+
this.requeueItem(item);
|
|
527
|
+
this.pollTimer = setTimeout(() => {
|
|
528
|
+
this.poll();
|
|
529
|
+
}, 10);
|
|
530
|
+
return;
|
|
531
|
+
}
|
|
519
532
|
this.consecutiveErrors = 0;
|
|
520
533
|
this.startJob(item.job, item.token);
|
|
521
534
|
}
|
|
@@ -566,6 +579,15 @@ export class Worker extends EventEmitter {
|
|
|
566
579
|
}
|
|
567
580
|
return item;
|
|
568
581
|
}
|
|
582
|
+
/** Put an item back at the front of the pending buffer (Issue #96). */
|
|
583
|
+
requeueItem(item) {
|
|
584
|
+
if (this.pendingJobsHead > 0) {
|
|
585
|
+
this.pendingJobs[--this.pendingJobsHead] = item;
|
|
586
|
+
}
|
|
587
|
+
else {
|
|
588
|
+
this.pendingJobs.unshift(item);
|
|
589
|
+
}
|
|
590
|
+
}
|
|
569
591
|
/**
|
|
570
592
|
* Get the next buffered job eligible for processing.
|
|
571
593
|
* When group concurrency is enabled, skips jobs whose group is at capacity
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "bunqueue",
|
|
3
|
-
"version": "2.8.
|
|
3
|
+
"version": "2.8.12",
|
|
4
4
|
"description": "High-performance job queue for Bun & AI agents. SQLite persistence, cron scheduling, priorities, retries, DLQ, webhooks, native MCP server. Zero external dependencies.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/main.js",
|