@nxtedition/scheduler 4.1.10 → 4.1.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.
package/README.md CHANGED
@@ -62,7 +62,7 @@ Unspecified priorities inherit the cap from the priority just below them — cap
62
62
 
63
63
  #### Starvation prevention
64
64
 
65
- Per-priority caps act as backpressure: when running tasks exceed a priority's cap, new tasks at that priority queue. If higher-priority tasks keep arriving, the capped queue could be starved indefinitely. To prevent that, the dispatch loop's fairness lottery (already used to give lower priorities a turn under uniform concurrency) **bypasses per-priority caps** when it picks a queued priority — so a fully-capped queue still drains slowly. The overall `max` is still respected.
65
+ Per-priority caps act as backpressure: when running tasks exceed a priority's cap, new tasks at that priority queue. If higher-priority tasks keep arriving, the capped queue could be starved indefinitely. To prevent that, the dispatch loop's fairness lottery (already used to give lower priorities a turn under uniform concurrency) **bypasses per-priority caps** when it picks a queued priority — so a fully-capped queue still drains slowly. The overall `max` is still respected. When the lottery picks an empty tier, its share goes to the highest-priority backlogged queue (within caps), so unused tiers never inflate lower-priority throughput.
66
66
 
67
67
  In `SharedArrayBuffer` mode, the second constructor argument carries per-priority limits (the buffer carries `max` across workers):
68
68
 
@@ -79,9 +79,9 @@ For more control, use `acquire` / `release` directly:
79
79
 
80
80
  ```js
81
81
  scheduler.acquire(
82
- (opaque) => {
82
+ async (opaque) => {
83
83
  try {
84
- doWork(opaque)
84
+ await doWork(opaque)
85
85
  } finally {
86
86
  scheduler.release()
87
87
  }
@@ -91,6 +91,8 @@ scheduler.acquire(
91
91
  )
92
92
  ```
93
93
 
94
+ **Error contract:** if `fn` throws **synchronously**, the scheduler releases the slot itself (the error propagates to the `acquire()` caller on the fast path, and surfaces as a deferred uncaught exception when thrown from a queued dispatch). Do **not** also call `release()` on the synchronous-throw path — a `try`/`finally` around _synchronous_ work would double-release and free a slot belonging to some other in-flight task. With an `async` callback as above the `finally` is correct: a rejecting async function does not throw synchronously, so the slot is yours to release exactly once.
95
+
94
96
  ### Multi-Worker Coordination
95
97
 
96
98
  Share a concurrency limit across worker threads using `SharedArrayBuffer`:
@@ -186,23 +188,35 @@ const { running, pending, queues } = scheduler.stats
186
188
 
187
189
  ### `scheduler.run(fn, priority?, opaque?): Promise<T>`
188
190
 
189
- Execute `fn` within the scheduler. Returns a promise that resolves with the return value of `fn`. After the scheduler has been disposed, `run()` rejects with `Error('Scheduler is disposed')` instead of hanging.
191
+ Execute `fn` within the scheduler. Returns a promise that resolves with the return value of `fn` (thenables are assimilated via `Promise.resolve`). After the scheduler has been disposed, `run()` rejects with `Error('Scheduler is disposed')` instead of hanging; with an overall concurrency of `0` (which could never dispatch anything) it rejects with `Error('Scheduler concurrency is 0')`.
190
192
 
191
193
  ### `scheduler.acquire(fn, priority?, opaque?): boolean`
192
194
 
193
- Low-level task acquisition. Returns `true` if a slot was available and `fn` ran synchronously, or `false` if the task was queued (also `false` if the scheduler has been disposed). You **must** call `scheduler.release()` when `fn` completes.
195
+ Low-level task acquisition. Returns `true` if a slot was available and `fn` ran synchronously, or `false` if the task was queued (also `false` if the scheduler has been disposed). The fast path additionally requires that nothing is queued at the same priority, preserving FIFO order within a priority; a fresh task can still start ahead of work queued at a _different_ priority while a freed slot is in flight (a deliberate latency trade-off, bounded to a microtask in shared mode). You **must** call `scheduler.release()` when `fn` completes — except when `fn` throws synchronously, in which case the scheduler has already released the slot (see the Low-Level API example).
196
+
197
+ ### `scheduler.tryAcquire(priority?): boolean`
198
+
199
+ Non-blocking. Takes a slot and returns `true` only if one is free at the given priority **and** nothing is queued at that priority (mirroring `limiter.tryConsume`); otherwise returns `false` without queuing. A successful `tryAcquire` must be paired with `release()`.
194
200
 
195
201
  ### `scheduler.release(): void`
196
202
 
197
203
  Signal task completion. Dequeues the next pending task if concurrency allows.
198
204
 
205
+ ### `scheduler.concurrency`
206
+
207
+ The overall concurrency ceiling (`Infinity` when unlimited). In shared mode this is the buffer's global `max`; a per-instance `options.concurrency.max` is enforced but not reflected here.
208
+
209
+ ### `scheduler.stats`
210
+
211
+ `{ running, pending, queues, shared }` — locally running tasks, locally queued tasks, per-priority queue counts, and (shared mode only) the global `{ running, waiters }` counters. Allocates fresh objects on every read; poll accordingly.
212
+
199
213
  ### `Scheduler.makeSharedState(concurrency): SharedArrayBuffer`
200
214
 
201
- Create shared state for cross-worker scheduling.
215
+ Create shared state for cross-worker scheduling. `concurrency` must be `Infinity` or a non-negative integer that fits in a signed 32-bit integer (≤ 2,147,483,647) — the counter is stored as `Int32`.
202
216
 
203
217
  ### `scheduler[Symbol.dispose]()`
204
218
 
205
- Disposes the scheduler: releases any global slots it still holds (shared mode), drops the reference to a pending shared-mode `Atomics.waitAsync`, and makes all further calls inert (`acquire` / `tryAcquire` return `false`; `run` rejects). Use when abandoning a shared-mode Scheduler with tasks still queued so the instance and its parked wait can be garbage-collected (it is otherwise kept alive until process exit so its held slots can be released). Works with `using`.
219
+ Disposes the scheduler: releases any global slots it still holds (shared mode), rejects queued `run()` promises with `Error('Scheduler is disposed')`, drops the reference to a pending shared-mode `Atomics.waitAsync`, and makes all further calls inert (`acquire` / `tryAcquire` return `false`; `run` rejects). Use when abandoning a shared-mode Scheduler with tasks still queued so the instance and its parked wait can be garbage-collected (it is otherwise kept alive until process exit so its held slots can be released). Works with `using`. Note that slots held by still-in-flight tasks are returned to the shared pool immediately — until those tasks actually finish, other workers can transiently admit more than `max` (the limit is soft by design).
206
220
 
207
221
  ### `parsePriority(value): number`
208
222
 
@@ -216,7 +230,7 @@ Parse a string or number into a normalized priority value.
216
230
 
217
231
  > Previously exported as `Throttle`. The `Throttle` alias is retained for backward compatibility but is **deprecated** — prefer `Limiter`.
218
232
 
219
- Tokens refill automatically: the constructor starts an internal `unref()`'d timer, and refills are also triggered lazily from `consume()` / `tryConsume()`. There is no manual refill step.
233
+ Tokens refill automatically: the constructor starts an internal timer, and refills are also triggered lazily from `consume()` / `tryConsume()`. There is no manual refill step. While work is queued the timer holds the event loop open (so a script never exits with queued callbacks silently dropped); an idle limiter does not keep the process alive.
220
234
 
221
235
  ### Basic
222
236
 
@@ -284,7 +298,7 @@ const ran = limiter.consume(
284
298
  )
285
299
  ```
286
300
 
287
- `consume` returns `true` if the callback ran immediately (tokens were available and nothing was queued ahead of it), or `false` if it was queued.
301
+ `consume` returns `true` if the callback ran immediately (tokens were available and nothing was queued ahead of it — the call refills the bucket from elapsed time first, so an idle or freshly created limiter answers `true` when the credit covers the request), or `false` if it was queued. Note the boundary is not airtight: a `false` (queued) task can still run synchronously _within_ the same call when the drain the call triggers reaches it immediately.
288
302
 
289
303
  ## API
290
304
 
@@ -297,12 +311,22 @@ const ran = limiter.consume(
297
311
 
298
312
  Consume `bytes` tokens, running `fn(opaque)` when they are available. Returns `true` if `fn` ran immediately, `false` if it was queued. `opaque` is passed through to `fn` on both paths.
299
313
 
300
- `bytes` must be a non-negative integer no larger than 2,147,483,647 (the signed Int32 max — tokens are tracked as `Int32`); negative, non-integer, `NaN`, `Infinity`, and out-of-range values throw (a negative or wrapping value would otherwise _add_ tokens via `Atomics.sub` and corrupt the shared bucket). A `bytes` of `0` consumes no tokens and never waits on the bucket. It runs immediately, returning `true`, only when nothing is queued at all (`pending === 0`); otherwise `consume` returns `false`, but the task is still serviced on the very next drain (which the call itself triggers) regardless of the token balance — even while the bucket is empty or in debt. So a weightless task is never blocked by a starved bucket, and it can drain ahead of token-starved work (priority is still honored among tasks that fit). A request larger than `tokensPerSecond` (the bucket's capacity) can never fit a full bucket; rather than stalling forever it is admitted once the bucket fills, drawing the bucket into debt that subsequent refills repay before any other work drains — i.e. it is throttled, not dropped.
314
+ `bytes` must be a non-negative integer no larger than 2,147,483,647 (the signed Int32 max — tokens are tracked as `Int32`); negative, non-integer, `NaN`, `Infinity`, and out-of-range values throw (a negative or wrapping value would otherwise _add_ tokens via `Atomics.sub` and corrupt the shared bucket). A `bytes` of `0` consumes no tokens and never waits on the bucket. It runs immediately, returning `true`, only when nothing is queued at all (`pending === 0`); otherwise `consume` returns `false`, but once it reaches the front of its priority queue it drains regardless of the token balance — even while the bucket is empty or in debt. Queued behind token-starved work at the same priority it waits its turn like any other task (FIFO head-of-line; a different, unblocked priority queue can drain it sooner).
315
+
316
+ **Starvation guard:** a queued task larger than the instantaneous token balance could otherwise starve under sustained traffic — smaller tasks would keep spending each refill's credit first. Any queue whose front item makes no progress for ~1 second is force-admitted into token debt; the negative balance is repaid by subsequent refills before anything else drains, so the long-run rate still holds (the trade-off is a transient burst, at most one stalled item per queue per second). The same mechanism bounds the wait for a request larger than `tokensPerSecond` (the bucket's capacity, which it could never fit): it is admitted once the bucket fills **or** the ~1s stall guard fires, whichever comes first — i.e. it is throttled, not dropped or stalled forever. In shared mode the guard is per-instance best-effort: other workers may keep consuming the shared bucket.
301
317
 
302
318
  ### `limiter.tryConsume(bytes): boolean`
303
319
 
304
320
  Non-blocking. Consumes `bytes` and returns `true` only if enough tokens are available right now and nothing is queued; otherwise returns `false` without queuing.
305
321
 
322
+ ### `limiter.tokensPerSecond`
323
+
324
+ The configured rate (and bucket capacity).
325
+
326
+ ### `limiter.stats`
327
+
328
+ `{ tokens, pending, queues }` — current token balance (negative while in debt), queued tasks, and per-priority queue counts. Allocates fresh objects on every read.
329
+
306
330
  ### `limiter.stream(priority?, options?): Transform`
307
331
 
308
332
  Returns a `Transform` stream that rate-limits data passing through it. Each chunk consumes `chunk.length` tokens; a chunk with no non-negative-integer `length` (e.g. in `objectMode`) is treated as weightless (0 tokens) — it never waits on tokens, though it still preserves the limiter's queue ordering (if other work is already queued, it drains in turn rather than jumping ahead). `options` is forwarded to the underlying `Transform` (e.g. `objectMode`, `highWaterMark`). Destroying the stream while a chunk is still queued in the limiter does not push into the dead stream.
@@ -1 +1 @@
1
- {"version":3,"file":"limiter.d.ts","sourceRoot":"","sources":["../src/limiter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,KAAK,gBAAgB,EAAE,MAAM,aAAa,CAAA;AAC9D,OAAO,EAAuC,KAAK,EAAE,KAAK,QAA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AE,QAAuB,EAAE,OAAO,CAAC,EAAE,gBAAgB;IA8BpE,OAAO,CAAC,EAAE,EAAE,MAAM,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,QAAQ,GAAG,OAAO;IACvE,OAAO,CAAC,CAAC,EACP,EAAE,EAAE,CAAC,MAAM,EAAE,CAAC,KAAK,OAAO,EAC1B,KAAK,EAAE,MAAM,EACb,QAAQ,EAAE,QAAQ,GAAG,SAAS,EAC9B,MAAM,EAAE,CAAC,GACR,OAAO;IAyEV,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO;CAqQnC"}
package/lib/limiter.js CHANGED
@@ -1,4 +1,5 @@
1
1
  import { Transform } from 'node:stream';
2
+ import { types } from 'node:util';
2
3
  import { FastQueue, NO_LIMITS, parsePriority, Queue } from "./queue.js";
3
4
  const LIMIT_INDEX = 0;
4
5
  const TOKENS_INDEX = 16; // separate cache line to avoid false sharing
@@ -10,6 +11,16 @@ const LIMITER_MAGIC = 0x4c494d54; // ASCII "LIMT" — sanity-check sentinel writ
10
11
  // value on store and silently breaks the bucket (it can never accrue), so reject it up
11
12
  // front rather than fail mysteriously at runtime.
12
13
  const MAX_TOKENS = 0x7fffffff; // 2_147_483_647
14
+ // Anti-starvation: a queue whose front item has sat undispatched for this many
15
+ // consecutive timer ticks (~1s at the 100ms cadence) is force-admitted into token
16
+ // debt. Without this, any front item larger than the instantaneous token balance
17
+ // starves indefinitely under saturation — the fallback scan spends every tick's
18
+ // fresh credit on smaller items from other queues, so the balance never reaches the
19
+ // big item (measured: a 600-of-1000-capacity item never ran during 5s of competing
20
+ // 100-byte traffic). The resulting negative balance throttles subsequent dispatches
21
+ // until the debt is repaid, so long-run rate conformance is preserved; the trade-off
22
+ // is a transient burst of at most one stalled front per queue per ~1s.
23
+ const STALL_TICKS = 10;
13
24
  function validateRate(tokensPerSecond) {
14
25
  if (tokensPerSecond == null ||
15
26
  !Number.isInteger(tokensPerSecond) ||
@@ -21,8 +32,29 @@ function validateRate(tokensPerSecond) {
21
32
  }
22
33
  export class Limiter extends Queue {
23
34
  stateView;
35
+ // True when stateView is backed by a SharedArrayBuffer (cross-worker bucket).
36
+ // Non-shared limiters are single-threaded, so the hot token decrement can use a
37
+ // plain write instead of a lock-prefixed Atomics RMW. Cold paths (#refill credit,
38
+ // force-through) keep Atomics unconditionally for simplicity.
39
+ #shared;
24
40
  pending = 0;
25
41
  #refillTimer;
42
+ // True while #refillTimer is scheduled to fire. Without this guard every #refill
43
+ // (one per queued consume) would call timer.refresh(), which removes + reinserts
44
+ // the timer in libuv's heap (~30% of the enqueue-path profile) AND perpetually
45
+ // postpones the deadline — under sustained consume() traffic the timer would
46
+ // never fire at its intended 100ms cadence.
47
+ #timerArmed = true;
48
+ // True while #refillTimer is ref'd (holding the event loop open). While pending > 0
49
+ // the timer is the ONLY thing that will ever service the queue, so it must keep the
50
+ // process alive — an unref'd timer let scripts exit mid-backlog with queued
51
+ // callbacks silently dropped (the README pipeline example truncated its output).
52
+ // When the queue is empty the timer is unref'd again so an idle limiter never
53
+ // pins the process.
54
+ #timerReffed = false;
55
+ // True when some queue's stall counter crossed STALL_TICKS at the last timer tick.
56
+ // Lets the drain loop skip the per-iteration stalled-queue scan in the common case.
57
+ #hasStalled = false;
26
58
  static makeSharedState(tokensPerSecond) {
27
59
  validateRate(tokensPerSecond);
28
60
  const stateBuffer = new SharedArrayBuffer(192); // 3 cache lines, one per field
@@ -43,7 +75,10 @@ export class Limiter extends Queue {
43
75
  }
44
76
  constructor(opts) {
45
77
  super();
46
- if (opts instanceof SharedArrayBuffer) {
78
+ // util.types.isSharedArrayBuffer instead of instanceof: a SAB from another realm
79
+ // (vm context, jest sandbox) fails instanceof and would fall through to the
80
+ // options branch with a misleading 'Invalid tokensPerSecond' error.
81
+ if (types.isSharedArrayBuffer(opts)) {
47
82
  if (opts.byteLength !== 192) {
48
83
  throw new Error('Invalid SharedArrayBuffer size');
49
84
  }
@@ -51,15 +86,23 @@ export class Limiter extends Queue {
51
86
  throw new Error('Invalid SharedArrayBuffer: not created by Limiter.makeSharedState');
52
87
  }
53
88
  this.stateView = new Int32Array(opts);
89
+ this.#shared = true;
54
90
  }
55
91
  else {
56
92
  const tokensPerSecond = validateRate(opts?.tokensPerSecond);
57
93
  this.stateView = new Int32Array(64);
58
94
  Atomics.store(this.stateView, LIMIT_INDEX, tokensPerSecond);
95
+ this.#shared = false;
59
96
  }
60
- this.#refillTimer = setTimeout(() => this.#refill(), 100).unref();
97
+ this.#refillTimer = setTimeout(() => {
98
+ this.#timerArmed = false;
99
+ this.#refill(true);
100
+ }, 100).unref();
61
101
  }
62
102
  stream(priority = Queue.NORMAL, options) {
103
+ // Parse once per stream instead of per chunk — consume() takes the cheap
104
+ // numeric path for an already-parsed priority.
105
+ const p = parsePriority(priority);
63
106
  return new Transform({
64
107
  ...options,
65
108
  // `chunk` is typed `unknown`, not `Buffer`: in object mode it can be any value —
@@ -72,13 +115,24 @@ export class Limiter extends Queue {
72
115
  // this callback later is harmless — a destroyed Transform drops the push, no `data`.
73
116
  transform: (chunk, _encoding, callback) => {
74
117
  const len = chunk?.length;
75
- const bytes = typeof len === 'number' && Number.isInteger(len) && len >= 0 ? len : 0;
118
+ // Clamp to MAX_TOKENS: a (pathological) length above the Int32 bound must not
119
+ // make consume() throw synchronously out of transform and wedge the stream.
120
+ const bytes = typeof len === 'number' && Number.isInteger(len) && len >= 0
121
+ ? len <= MAX_TOKENS
122
+ ? len
123
+ : MAX_TOKENS
124
+ : 0;
76
125
  // eslint-disable-next-line typescript-eslint/no-unsafe-argument
77
- this.consume((chunk) => callback(null, chunk), bytes, priority, chunk);
126
+ this.consume((chunk) => callback(null, chunk), bytes, p, chunk);
78
127
  },
79
128
  });
80
129
  }
81
130
  consume(fn, bytes, priority = Queue.NORMAL, opaque) {
131
+ if (typeof fn !== 'function') {
132
+ // Validate up front: a queued non-function would otherwise detonate later
133
+ // inside the drain loop, surfacing as an unattributable deferred error.
134
+ throw new Error('Invalid fn');
135
+ }
82
136
  // bytes must be a non-negative Int32 integer: it is applied to Atomics.sub on an
83
137
  // Int32Array, so a negative value (or one that wraps past the Int32 max) *adds*
84
138
  // tokens — corrupting the shared bucket for every worker — and NaN/Infinity can never
@@ -90,16 +144,45 @@ export class Limiter extends Queue {
90
144
  if (priority == null) {
91
145
  priority = Queue.NORMAL;
92
146
  }
93
- if (this.pending === 0 && this.#tryConsumeTokens(bytes)) {
94
- fn(opaque);
95
- return true;
147
+ if (this.pending === 0) {
148
+ if (this.#tryConsumeTokens(bytes)) {
149
+ fn(opaque);
150
+ return true;
151
+ }
152
+ // The stored balance is stale until a refill credits elapsed time — without
153
+ // this, the first consume on a fresh/idle limiter always queued (and then ran
154
+ // synchronously from the queued-path #refill below while still returning
155
+ // false, breaking the documented "true if fn ran immediately" contract).
156
+ // With pending === 0 the refill's drain loop is a no-op, so this only
157
+ // advances the clock; ordering is unaffected.
158
+ this.#refill();
159
+ if (this.#tryConsumeTokens(bytes)) {
160
+ fn(opaque);
161
+ return true;
162
+ }
96
163
  }
97
164
  const p = parsePriority(priority);
98
165
  const queue = this.queues[p + 3];
99
166
  this.pending += 1;
100
167
  queue.arr.push(fn, bytes, opaque);
101
168
  queue.cnt += 1;
102
- this.#refill();
169
+ if (queue.cnt === 1) {
170
+ this.nonEmptyMask |= 1 << queue.i;
171
+ }
172
+ // Only attempt a synchronous credit + drain when it can matter:
173
+ // - first backlog item (pending === 1): nothing has attempted a drain for it
174
+ // yet, and tokens may have accrued since the last refill;
175
+ // - weightless (0-byte) task: never waits on tokens, must drain immediately
176
+ // even while the bucket is in debt;
177
+ // - timer not armed: nobody else will service the queue, so arm it here.
178
+ // Otherwise the armed timer services the backlog within its 100ms cadence and
179
+ // a synchronous #refill per enqueue is pure overhead (performance.now() + a
180
+ // failed drain scan per call, ~half the enqueue-path cost under bursts). The
181
+ // trade-off is up to one timer tick of extra latency for an item queued behind
182
+ // an existing backlog — within the limiter's natural 100ms granularity.
183
+ if (bytes === 0 || this.pending === 1 || !this.#timerArmed) {
184
+ this.#refill();
185
+ }
103
186
  return false;
104
187
  }
105
188
  tryConsume(bytes) {
@@ -128,23 +211,49 @@ export class Limiter extends Queue {
128
211
  // oversized requests only make progress via the queued drain loop in #refill(), which
129
212
  // forces them through into debt once the bucket is full. This keeps tryConsume() a
130
213
  // true non-blocking poll and never grants more than the bucket can hold on the fast path.
131
- if (this.stateView[TOKENS_INDEX] < bytes) {
214
+ const tokens = this.stateView[TOKENS_INDEX];
215
+ if (tokens < bytes) {
132
216
  return false;
133
217
  }
134
- Atomics.sub(this.stateView, TOKENS_INDEX, bytes);
218
+ if (this.#shared) {
219
+ Atomics.sub(this.stateView, TOKENS_INDEX, bytes);
220
+ }
221
+ else {
222
+ // Single-threaded: a plain write avoids the lock-prefixed RMW on the hottest path.
223
+ this.stateView[TOKENS_INDEX] = tokens - bytes;
224
+ }
135
225
  return true;
136
226
  }
137
- #refill() {
227
+ // fromTimer is true only for the 100ms cadence timer callback: stall bookkeeping
228
+ // ticks on the timer (not on consume-triggered drains) so its time base is real
229
+ // elapsed time, independent of traffic volume.
230
+ #refill(fromTimer = false) {
231
+ if (fromTimer && this.pending > 0) {
232
+ // A queue with items whose front didn't dispatch since the last tick is
233
+ // stalling (every dispatch from a queue resets its counter in the drain
234
+ // loop below). Crossing STALL_TICKS arms the force-through in the drain.
235
+ for (let p = 0; p < this.queues.length; p++) {
236
+ const q = this.queues[p];
237
+ if (q.cnt > 0 && ++q.stall >= STALL_TICKS) {
238
+ this.#hasStalled = true;
239
+ }
240
+ }
241
+ }
138
242
  const rate = this.tokensPerSecond;
139
243
  const currentToken = this.stateView[TOKENS_INDEX];
140
244
  const refillTime = this.stateView[REFILL_INDEX];
141
245
  // performance.now() | 0 is integer ms since process start, kept in Int32 range so it
142
246
  // matches REFILL_INDEX's Int32 storage. Date.now() (~1.74 trillion) would overflow Int32.
247
+ // `|| 1` wherever a value is stored as the anchor: 0 doubles as the never-anchored
248
+ // sentinel below, and a real clock reading of 0 (process's first ms, or the Int32
249
+ // wrap passing through 0) written as an anchor would re-trigger the fill-to-capacity
250
+ // first-refill branch on every subsequent call. A 1ms skew is far below the
251
+ // limiter's 100ms granularity.
143
252
  const now = performance.now() | 0;
144
253
  if (refillTime === 0) {
145
254
  // First refill anchors the clock and fills the bucket to capacity. CAS so that when
146
255
  // multiple workers race the very first refill, only one of them performs the fill.
147
- if (Atomics.compareExchange(this.stateView, REFILL_INDEX, 0, now) === 0) {
256
+ if (Atomics.compareExchange(this.stateView, REFILL_INDEX, 0, now || 1) === 0) {
148
257
  const fill = rate - currentToken;
149
258
  if (fill > 0) {
150
259
  Atomics.add(this.stateView, TOKENS_INDEX, fill);
@@ -158,7 +267,7 @@ export class Limiter extends Queue {
158
267
  // Negative elapsed = the Int32 ms counter wrapped (~24.8 days); room <= 0 = the
159
268
  // bucket is already at/over capacity (a full bucket cannot bank time). Either way,
160
269
  // re-anchor the clock to now and drop the carried fraction without crediting.
161
- Atomics.compareExchange(this.stateView, REFILL_INDEX, refillTime, now);
270
+ Atomics.compareExchange(this.stateView, REFILL_INDEX, refillTime, now || 1);
162
271
  }
163
272
  else {
164
273
  // Tokens accrue at `rate` per 1000ms. Credit only whole tokens and advance the
@@ -176,16 +285,20 @@ export class Limiter extends Queue {
176
285
  // Bucket fills this tick: clamp to capacity and snap the clock to now —
177
286
  // overflow time cannot be banked.
178
287
  granted = room;
179
- newRefillTime = now;
288
+ newRefillTime = now || 1;
180
289
  }
181
290
  else {
182
291
  // floor(granted * 1000 / rate) <= elapsedMs, so the clock never passes now;
183
292
  // the un-advanced remainder (worth < one token) carries forward.
184
- newRefillTime = refillTime + Math.floor((granted * 1000) / rate);
293
+ newRefillTime = refillTime + Math.floor((granted * 1000) / rate) || 1;
185
294
  }
186
295
  // Gate the credit on the REFILL CAS so concurrent refills across workers never
187
296
  // double-count the same elapsed window: only the winner advances the clock and
188
- // adds tokens.
297
+ // adds tokens. NB: the credit below is a separate atomic op — a worker
298
+ // descheduled here for >= room/rate seconds while another worker completes a
299
+ // full refill can transiently push tokens above capacity (bounded by `rate`,
300
+ // self-correcting on the next refill via the room <= 0 re-anchor). Accepted as
301
+ // the over-grant mirror of the documented brief-debt soft-limit race.
189
302
  if (Atomics.compareExchange(this.stateView, REFILL_INDEX, refillTime, newRefillTime) ===
190
303
  refillTime) {
191
304
  Atomics.add(this.stateView, TOKENS_INDEX, granted);
@@ -203,45 +316,70 @@ export class Limiter extends Queue {
203
316
  // the whole debt-repayment window. When nothing else fits, the scan below returns
204
317
  // promptly (it never force-dispatches unless the bucket is full), so this does not spin.
205
318
  while (this.pending > 0) {
206
- let queue = this.getNextQueue(NO_LIMITS, 0);
207
- if (queue == null || queue.cnt === 0) {
208
- break;
209
- }
210
- if (!this.#tryConsumeTokens(queue.arr[queue.idx + 1])) {
211
- // The preferred queue's front task doesn't fit; scan all queues from
212
- // highest to lowest priority for any task whose byte requirement fits
213
- // within available tokens (starvation prevention).
214
- queue = null;
215
- let highest = null;
319
+ let queue = null;
320
+ // Anti-starvation force-through (see STALL_TICKS): the highest-priority queue
321
+ // whose front has been blocked for >= STALL_TICKS timer ticks dispatches into
322
+ // debt, regardless of the current balance. Without this, the fallback scan
323
+ // below spends every tick's fresh credit on smaller items so a large front
324
+ // never sees enough tokens and an oversized (> capacity) front could only
325
+ // ever force through via the bucket-completely-full branch, which sustained
326
+ // traffic postpones indefinitely.
327
+ if (this.#hasStalled) {
328
+ this.#hasStalled = false;
216
329
  for (let p = this.queues.length - 1; p >= 0; p--) {
217
330
  const q = this.queues[p];
218
- if (q.cnt === 0) {
219
- continue;
220
- }
221
- if (highest === null) {
222
- highest = q;
223
- }
224
- if (this.#tryConsumeTokens(q.arr[q.idx + 1])) {
331
+ if (q.cnt > 0 && q.stall >= STALL_TICKS) {
332
+ if (!this.#tryConsumeTokens(q.arr[q.idx + 1])) {
333
+ Atomics.sub(this.stateView, TOKENS_INDEX, q.arr[q.idx + 1]);
334
+ }
225
335
  queue = q;
226
336
  break;
227
337
  }
228
338
  }
229
- if (queue == null) {
230
- // Nothing fits the tokens available right now. If the bucket is already full
231
- // (at capacity — it can never hold more), every remaining task is larger than
232
- // the bucket can ever cover, so waiting is pointless and they would stall
233
- // forever. Force the highest-priority such task through into debt; the
234
- // tokens < 0 result drops out of this loop and subsequent refills repay the
235
- // debt before anything else drains — the correct throttle for an over-large unit.
236
- if (highest !== null && this.stateView[TOKENS_INDEX] >= this.stateView[LIMIT_INDEX]) {
237
- Atomics.sub(this.stateView, TOKENS_INDEX, highest.arr[highest.idx + 1]);
238
- queue = highest;
339
+ }
340
+ if (queue == null) {
341
+ queue = this.getNextQueue(NO_LIMITS, 0);
342
+ if (queue == null || queue.cnt === 0) {
343
+ break;
344
+ }
345
+ if (!this.#tryConsumeTokens(queue.arr[queue.idx + 1])) {
346
+ // The preferred queue's front task doesn't fit; scan all queues from
347
+ // highest to lowest priority for any task whose byte requirement fits
348
+ // within available tokens (starvation prevention).
349
+ queue = null;
350
+ let highest = null;
351
+ for (let p = this.queues.length - 1; p >= 0; p--) {
352
+ const q = this.queues[p];
353
+ if (q.cnt === 0) {
354
+ continue;
355
+ }
356
+ if (highest === null) {
357
+ highest = q;
358
+ }
359
+ if (this.#tryConsumeTokens(q.arr[q.idx + 1])) {
360
+ queue = q;
361
+ break;
362
+ }
239
363
  }
240
- else {
241
- return;
364
+ if (queue == null) {
365
+ // Nothing fits the tokens available right now. If the bucket is already full
366
+ // (at capacity — it can never hold more), every remaining task is larger than
367
+ // the bucket can ever cover, so waiting is pointless and they would stall
368
+ // forever. Force the highest-priority such task through into debt; the
369
+ // tokens < 0 result drops out of this loop and subsequent refills repay the
370
+ // debt before anything else drains — the correct throttle for an over-large unit.
371
+ if (highest !== null && this.stateView[TOKENS_INDEX] >= this.stateView[LIMIT_INDEX]) {
372
+ Atomics.sub(this.stateView, TOKENS_INDEX, highest.arr[highest.idx + 1]);
373
+ queue = highest;
374
+ }
375
+ else {
376
+ return;
377
+ }
242
378
  }
243
379
  }
244
380
  }
381
+ // Dispatching from a queue means its front is making progress.
382
+ queue.stall = 0;
245
383
  const fn = queue.arr[queue.idx];
246
384
  const opaque = queue.arr[queue.idx + 2];
247
385
  queue.arr[queue.idx++] = null;
@@ -250,6 +388,7 @@ export class Limiter extends Queue {
250
388
  queue.cnt -= 1;
251
389
  this.pending -= 1;
252
390
  if (queue.cnt === 0) {
391
+ this.nonEmptyMask &= ~(1 << queue.i);
253
392
  queue.idx = 0;
254
393
  // See scheduler.ts: `arr = []` beats `length = 0` in V8 on this hot path.
255
394
  queue.arr = [];
@@ -276,7 +415,21 @@ export class Limiter extends Queue {
276
415
  }
277
416
  finally {
278
417
  if (this.pending > 0) {
279
- this.#refillTimer.refresh();
418
+ if (!this.#timerArmed) {
419
+ this.#timerArmed = true;
420
+ this.#refillTimer.refresh();
421
+ }
422
+ // While work is queued the timer is the only thing guaranteed to service
423
+ // it — hold the event loop open or a script with nothing else pending
424
+ // exits mid-backlog, silently dropping the queued callbacks.
425
+ if (!this.#timerReffed) {
426
+ this.#timerReffed = true;
427
+ this.#refillTimer.ref();
428
+ }
429
+ }
430
+ else if (this.#timerReffed) {
431
+ this.#timerReffed = false;
432
+ this.#refillTimer.unref();
280
433
  }
281
434
  }
282
435
  }
@@ -1 +1 @@
1
- {"version":3,"file":"limiter.js","sourceRoot":"","sources":["../src/limiter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAyB,MAAM,aAAa,CAAA;AAC9D,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,aAAa,EAAE,KAAK,EAAiB,MAAM,YAAY,CAAA;AAEtF,MAAM,WAAW,GAAG,CAAC,CAAA;AACrB,MAAM,YAAY,GAAG,EAAE,CAAA,CAAC,6CAA6C;AACrE,MAAM,YAAY,GAAG,EAAE,CAAA,CAAC,6CAA6C;AACrE,MAAM,WAAW,GAAG,CAAC,CAAA,CAAC,oDAAoD;AAC1E,MAAM,aAAa,GAAG,UAAU,CAAA,CAAC,kEA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AAC,CAAC,CAAA;gBACJ,CAAC;YACH,CAAC;QACH,CAAC;gBAAS,CAAC;YACT,IAAI,IAAI,CAAC,OAAO,GAAG,CAAC,EAAE,CAAC;gBACrB,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC;oBACtB,IAAI,CAAC,WAAW,GAAG,IAAI,CAAA;oBACvB,IAAI,CAAC,YAAY,CAAC,OAAO,EAAE,CAAA;gBAC7B,CAAC;gBACD,yEAAyE;gBACzE,sEAAsE;gBACtE,6DAA6D;gBAC7D,IAAI,CAAC,IAAI,CAAC,YAAY,EAAE,CAAC;oBACvB,IAAI,CAAC,YAAY,GAAG,IAAI,CAAA;oBACxB,IAAI,CAAC,YAAY,CAAC,GAAG,EAAE,CAAA;gBACzB,CAAC;YACH,CAAC;iBAAM,IAAI,IAAI,CAAC,YAAY,EAAE,CAAC;gBAC7B,IAAI,CAAC,YAAY,GAAG,KAAK,CAAA;gBACzB,IAAI,CAAC,YAAY,CAAC,KAAK,EAAE,CAAA;YAC3B,CAAC;QACH,CAAC;IACH,CAAC;CACF"}
package/lib/queue.d.ts CHANGED
@@ -2,6 +2,9 @@ export declare class FastQueue {
2
2
  idx: number;
3
3
  cnt: number;
4
4
  arr: Array<unknown>;
5
+ stall: number;
6
+ readonly i: number;
7
+ constructor(i: number);
5
8
  }
6
9
  export type NumberPriority = -3 | -2 | -1 | 0 | 1 | 2 | 3;
7
10
  export type Priority = NumberPriority | 'lowest' | 'lower' | 'low' | 'normal' | 'high' | 'higher' | 'highest';
@@ -16,6 +19,7 @@ export declare class Queue {
16
19
  static readonly HIGHER = 2;
17
20
  static readonly HIGHEST = 3;
18
21
  private counter;
22
+ protected nonEmptyMask: number;
19
23
  protected queues: FastQueue[];
20
24
  protected getNextQueue(limits: number[], running: number): FastQueue | null;
21
25
  }
@@ -1 +1 @@
1
- {"version":3,"file":"queue.d.ts","sourceRoot":"","sources":["../src/queue.ts"],"names":[],"mappings":"AAAA,qBAAa,SAAS;IACpB,GAAG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C,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAA;AAEzD,MAAM,MAAM,QAAQ,GAChB,cAAc,GACd,QAAQ,GACR,OAAO,GACP,KAAK,GACL,QAAQ,GACR,MAAM,GACN,QAAQ,GACR,SAAS,CAAA;AAEb,wBAAgB,aAAa,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,cAAc,CA8BhE;AAsBD,eAAO,MAAM,SAAS,EAAE,MAAM,EAQ7B,CAAA;AAED,qBAAa,KAAK;IAChB,MAAM,CAAC,QAAQ,CAAC,MAAM,MAAK;IAC3B,MAAM,CAAC,QAAQ,CAAC,KAAK,MAAK;IAC1B,MAAM,CAAC,QAAQ,CAAC,GAAG,MAAK;IACxB,MAAM,CAAC,QAAQ,CAAC,MAAM,KAAI;IAC1B,MAAM,CAAC,QAAQ,CAAC,IAAI,KAAI;IACxB,MAAM,CAAC,QAAQ,CAAC,MAAM,KAAI;IAC1B,MAAM,CAAC,QAAQ,CAAC,OAAO,KAAI;IAE3B,OAAO,CAAC,OAAO,CAAI;IAKnB,SAAS,CAAC,YAAY,SAAI;IAG1B,SAAS,CAAC,MAAM,cAQf;IAaD,SAAS,CAAC,YAAY,CAAC,MAAM,EAAE,MAAM,EAAE,EAAE,OAAO,EAAE,MAAM;CAiCzD"}
package/lib/queue.js CHANGED
@@ -2,6 +2,16 @@ export class FastQueue {
2
2
  idx = 0;
3
3
  cnt = 0;
4
4
  arr = [];
5
+ // Consecutive Limiter timer ticks during which this queue had items but dispatched
6
+ // nothing (front blocked on tokens). Unused by Scheduler. See Limiter's
7
+ // anti-starvation force-through.
8
+ stall = 0;
9
+ // This queue's index in Queue.queues (priority + 3), so dequeue sites can update
10
+ // the owner's nonEmptyMask without searching.
11
+ i;
12
+ constructor(i) {
13
+ this.i = i;
14
+ }
5
15
  }
6
16
  export function parsePriority(p) {
7
17
  if (typeof p === 'number') {
@@ -45,6 +55,20 @@ export function parsePriority(p) {
45
55
  }
46
56
  }
47
57
  const maxInt = 2147483647;
58
+ // Lottery tier for each value of (counter & 127): the lowest set bit among bits 0..6
59
+ // picks the tier (bit0 → highest=6, bit1 → 5, …, bit6 → lowest=0); no bit set → 6.
60
+ // Precomputed so the hot dispatch path does one table load instead of a branch chain.
61
+ const TIER = new Uint8Array(128);
62
+ for (let v = 0; v < 128; v++) {
63
+ let idx = 6;
64
+ for (let b = 0; b < 7; b++) {
65
+ if (v & (1 << b)) {
66
+ idx = 6 - b;
67
+ break;
68
+ }
69
+ }
70
+ TIER[v] = idx;
71
+ }
48
72
  // Sentinel limits array for callers that don't enforce per-priority caps.
49
73
  // `running < NO_LIMITS[n]` is always true for any non-negative running count,
50
74
  // so passing this acts as "no filter".
@@ -66,15 +90,19 @@ export class Queue {
66
90
  static HIGHER = 2;
67
91
  static HIGHEST = 3;
68
92
  counter = 0;
93
+ // Bit n is set while queues[n] is non-empty. Maintained by subclasses at the
94
+ // 0 ↔ non-0 cnt transitions (enqueue/dequeue/clear), which are rare relative to
95
+ // dispatches, so getNextQueue can skip empty tiers without touching their objects.
96
+ nonEmptyMask = 0;
69
97
  // Queues are stored in order of priority, so index == priority + 3
70
98
  queues = [
71
- new FastQueue(), // 0 lowest
72
- new FastQueue(), // 1 lower
73
- new FastQueue(), // 2 low
74
- new FastQueue(), // 3 normal
75
- new FastQueue(), // 4 high
76
- new FastQueue(), // 5 higher
77
- new FastQueue(), // 6 highest
99
+ new FastQueue(0), // 0 lowest
100
+ new FastQueue(1), // 1 lower
101
+ new FastQueue(2), // 2 low
102
+ new FastQueue(3), // 3 normal
103
+ new FastQueue(4), // 4 high
104
+ new FastQueue(5), // 5 higher
105
+ new FastQueue(6), // 6 highest
78
106
  ];
79
107
  // Pick the next queue to dispatch from.
80
108
  //
@@ -88,45 +116,30 @@ export class Queue {
88
116
  // turn, defeating starvation prevention. Use `running = -1` to bypass limits on
89
117
  // every queue (e.g. when the local worker has nothing running).
90
118
  getNextQueue(limits, running) {
91
- this.counter = (this.counter + 1) & maxInt;
92
- let idx = this.queues.length - 1;
93
- if (this.counter & 0b0000001) {
94
- idx = 6; // highest: 50%
95
- }
96
- else if (this.counter & 0b0000010) {
97
- idx = 5; // higher: 25%
98
- }
99
- else if (this.counter & 0b0000100) {
100
- idx = 4; // high: 12.5%
101
- }
102
- else if (this.counter & 0b0001000) {
103
- idx = 3; // normal: 6.25%
104
- }
105
- else if (this.counter & 0b0010000) {
106
- idx = 2; // low: 3.125%
107
- }
108
- else if (this.counter & 0b0100000) {
109
- idx = 1; // lower: 1.5625%
110
- }
111
- else if (this.counter & 0b1000000) {
112
- idx = 0; // lowest: 0.78%
119
+ const mask = this.nonEmptyMask;
120
+ if (mask === 0) {
121
+ return null;
113
122
  }
123
+ this.counter = (this.counter + 1) & maxInt;
124
+ const idx = TIER[this.counter & 127];
114
125
  // Lottery-selected queue: bypass its limit (starvation prevention).
115
- const preferred = this.queues[idx];
116
- if (preferred.cnt > 0) {
117
- return preferred;
118
- }
119
- for (let n = idx - 1; n >= 0; n--) {
120
- const q = this.queues[n];
121
- if (q.cnt > 0 && running < limits[n]) {
122
- return q;
123
- }
126
+ if (mask & (1 << idx)) {
127
+ return this.queues[idx];
124
128
  }
125
- for (let n = this.queues.length - 1; n > idx; n--) {
126
- const q = this.queues[n];
127
- if (q.cnt > 0 && running < limits[n]) {
128
- return q;
129
+ // Preferred tier empty: highest-first scan over the NON-EMPTY tiers only (with
130
+ // limit checks), so an empty tier's lottery mass reverts to the most important
131
+ // backlogged work. Scanning downward first instead would hand every empty middle
132
+ // tier's share to LOWER priorities — measured at ~44-47% of dispatch slots going
133
+ // to a backlogged 'low'/'normal' tier while 'highest' was backlogged, versus the
134
+ // ~3-6% the documented exponential bias promises. Iterating set bits via clz32
135
+ // visits only populated tiers (usually one) instead of all seven queue objects.
136
+ let m = mask;
137
+ while (m !== 0) {
138
+ const n = 31 - Math.clz32(m);
139
+ if (running < limits[n]) {
140
+ return this.queues[n];
129
141
  }
142
+ m &= ~(1 << n);
130
143
  }
131
144
  return null;
132
145
  }
package/lib/queue.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"queue.js","sourceRoot":"","sources":["../src/queue.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,SAAS;IACpB,GAAG,GAAG,CAAC,CAAA;IACP,GAAG,GAAG,CAAC,CAAA;IACP,GAAG,GAAmB,EAAE,CAAA;CACzB;AAcD,MAAM,UAAU,aAAa,CAAC,CAAkB;IAC9C,IAAI,OAAO,CAAC,KAAK,QAAQ,EAAE,CAAC;QAC1B,gBAAgB;IAClB,CAAC;SAAM,IAAI,CAAC,KAAK,QAAQ,EAAE,CAAC;QAC1B,OAAO,CAAC,CAAC,CAAA;IACX,CAAC;SAAM,IAAI,CAAC,KAAK,OAAO,EAAE,CAAC;QACzB,OAAO,CAAC,CAAC,CAAA;IACX,CAAC;SAAM,IAAI,CAAC,KAAK,KAAK,EAAE,CAAC;QACvB,OAAO,CAAC,CAAC,CAAA;IACX,CAAC;SAAM,IAAI,CAAC,KAAK,QAAQ,EAAE,CAAC;QAC1B,OAAO,CAAC,CAAA;IACV,CAAC;SAAM,IAAI,CAAC,KAAK,MAAM,EAAE,CAAC;QACxB,OAAO,CAAC,CAAA;IACV,CAAC;SAAM,IAAI,CAAC,KAAK,QAAQ,EAAE,CAAC;QAC1B,OAAO,CAAC,CAAA;IACV,CAAC;SAAM,IAAI,CAAC,KAAK,SAAS,EAAE,CAAC;QAC3B,OAAO,CAAC,CAAA;IACV,CAAC;SAAM,CAAC;QACN,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,CAAA;IACf,CAAC;IAED,IAAI,OAAO,CAAC,KAAK,QAAQ,IAAI,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC;QAC7C,OAAO,CAAC,CAAA;IACV,CAAC;SAAM,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC;QAClB,OAAO,CAAC,CAAC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js";
2
3
  // Layout of the 128-byte (32 × Int32) shared state buffer:
3
4
  //
@@ -17,6 +18,12 @@ const MAGIC_INDEX = 8;
17
18
  const CONCURRENCY_INDEX = 16;
18
19
  const WAITERS_INDEX = 24;
19
20
  const SCHEDULER_MAGIC = 0x5ca4edde; // sanity-check sentinel written by makeSharedState
21
+ // CONCURRENCY is stored in an Int32 slot. A finite value above this would silently
22
+ // wrap on store (2**31 → -2147483648 → "unlimited", 2**32 → 0 → permanent hang), so
23
+ // values that don't fit are either rejected (makeSharedState) or reported as
24
+ // Infinity by the `concurrency` getter (non-shared mode, where the real limit is
25
+ // still enforced via #limits/#max as ordinary numbers).
26
+ const MAX_INT32 = 0x7fffffff;
20
27
  // Per-priority limit keys, ordered to match `Queue.queues` (lowest=0, normal=3, highest=6).
21
28
  const PRIORITY_KEYS = ['lowest', 'lower', 'low', 'normal', 'high', 'higher', 'highest'];
22
29
  // Reject anything that isn't a literal config object — Map/Date/Array/class instances all
@@ -141,7 +148,13 @@ export class Scheduler extends Queue {
141
148
  try {
142
149
  const result = fn(opaque);
143
150
  if (result != null && typeof result.then === 'function') {
144
- void result.then(resolve, reject).then(this.release);
151
+ // Promise.resolve assimilates the thenable: identity for native promises (no
152
+ // hot-path allocation), and for user thenables it restores the Promises/A+
153
+ // guarantees raw .then lacks — a then() that returns undefined no longer
154
+ // TypeErrors the chain, a thenable that calls its callback twice can no
155
+ // longer double-release the slot, and release is chained off a real promise
156
+ // instead of whatever object the thenable's then() happened to return.
157
+ void Promise.resolve(result).then(resolve, reject).then(this.release);
145
158
  }
146
159
  else {
147
160
  resolve(result);
@@ -157,7 +170,10 @@ export class Scheduler extends Queue {
157
170
  if (concurrency === Infinity) {
158
171
  concurrency = -1;
159
172
  }
160
- else if (concurrency == null || !Number.isInteger(concurrency) || concurrency < 0) {
173
+ else if (concurrency == null ||
174
+ !Number.isInteger(concurrency) ||
175
+ concurrency < 0 ||
176
+ concurrency > MAX_INT32) {
161
177
  throw new Error('Invalid concurrency');
162
178
  }
163
179
  const stateBuffer = new SharedArrayBuffer(128); // 2 cache lines, one per field
@@ -188,7 +204,10 @@ export class Scheduler extends Queue {
188
204
  if (options != null && !isPlainObject(options)) {
189
205
  throw new Error('Invalid options');
190
206
  }
191
- if (optsOrArrayBuffer instanceof SharedArrayBuffer) {
207
+ // util.types.isSharedArrayBuffer instead of instanceof: a SAB from another realm
208
+ // (vm context, jest sandbox) fails instanceof and would fall into the options
209
+ // branch with a misleading 'Invalid options' error.
210
+ if (types.isSharedArrayBuffer(optsOrArrayBuffer)) {
192
211
  const state = optsOrArrayBuffer;
193
212
  if (state.byteLength !== 128) {
194
213
  throw new Error('Invalid SharedArrayBuffer size');
@@ -216,7 +235,9 @@ export class Scheduler extends Queue {
216
235
  const { limits, max } = buildLimits(opts?.concurrency);
217
236
  this.stateView = new Int32Array(64);
218
237
  // Persist `max` so the public `concurrency` getter still reflects the overall ceiling.
219
- Atomics.store(this.stateView, CONCURRENCY_INDEX, max === Number.MAX_SAFE_INTEGER ? -1 : max);
238
+ // Values that don't fit Int32 are effectively unlimited — report them as Infinity
239
+ // (-1 sentinel) instead of letting the store wrap to garbage.
240
+ Atomics.store(this.stateView, CONCURRENCY_INDEX, max > MAX_INT32 ? -1 : max);
220
241
  this.shared = false;
221
242
  this.#limits = limits;
222
243
  this.#max = max;
@@ -264,6 +285,11 @@ export class Scheduler extends Queue {
264
285
  }
265
286
  }
266
287
  run(fn, priority = Queue.NORMAL, opaque) {
288
+ if (typeof fn !== 'function') {
289
+ // Validate up front: a queued non-function would otherwise detonate later
290
+ // inside the dispatch loop, mis-attributed to whoever triggered the drain.
291
+ throw new Error('Invalid fn');
292
+ }
267
293
  return new Promise((resolve, reject) => {
268
294
  // After dispose/exit the scheduler is inert: #tryAcquire returns false and
269
295
  // acquire() refuses to queue, so without this guard the returned promise would
@@ -273,25 +299,51 @@ export class Scheduler extends Queue {
273
299
  reject(new Error('Scheduler is disposed'));
274
300
  return;
275
301
  }
302
+ // A hard cap of 0 can never dispatch anything (even the lottery bypass is
303
+ // gated on running < max), so the promise would hang forever. Fail fast,
304
+ // mirroring the disposed-scheduler rejection above.
305
+ if (this.#max === 0) {
306
+ reject(new Error('Scheduler concurrency is 0'));
307
+ return;
308
+ }
276
309
  const ctx = { resolve, reject, fn, opaque };
277
310
  const p = parsePriority(priority);
278
- if (this.#tryAcquire(p)) {
279
- // Fast path: slot available immediately call #runTask directly.
311
+ if (this.queues[p + 3].cnt === 0 && this.#tryAcquire(p)) {
312
+ // Fast path: nothing queued ahead of us at this priority and a slot is
313
+ // available immediately — call #runTask directly. The same-priority gate
314
+ // preserves FIFO within a priority: without it a fresh task could overtake
315
+ // work queued at the same priority during the (shared-mode) microtask window
316
+ // between a remote release and the parked waiter's wakeup.
280
317
  this.#runTask(ctx);
281
318
  }
282
319
  else {
283
- // Slow path: no slot — queue the work via acquire.
284
- this.acquire(this.#runTask, priority, ctx);
320
+ // Slow path: no slot — queue the work via acquire. Pass the already-parsed
321
+ // numeric priority so acquire's parsePriority takes its cheap numeric path.
322
+ this.acquire(this.#runTask, p, ctx);
285
323
  }
286
324
  });
287
325
  }
288
326
  acquire(fn, priority = Queue.NORMAL, opaque) {
327
+ if (typeof fn !== 'function') {
328
+ // Validate up front: a queued non-function would otherwise detonate later
329
+ // inside the dispatch loop, mis-attributed to whoever triggered the drain.
330
+ throw new Error('Invalid fn');
331
+ }
289
332
  if (this.dead) {
290
333
  return false;
291
334
  }
292
335
  const p = priority == null ? Queue.NORMAL : parsePriority(priority);
293
- const queue = this.queues[p + 3];
294
- if (this.#tryAcquire(p)) {
336
+ // Snapshot RUNNING *before* the capacity check. If a remote release lands
337
+ // between a failed #tryAcquire and the Atomics.waitAsync in #maybeWait, its
338
+ // Atomics.notify fires while WAITERS is still 0 and is skipped — a lost
339
+ // wakeup. Parking on this pre-check snapshot closes the race: waitAsync
340
+ // compares the current value against `expected`, sees the release's
341
+ // decrement (value !== expected), resolves immediately and re-dispatches.
342
+ // A fresh read taken after the failed check would match the post-release
343
+ // value and park forever on a queue nobody will ever notify.
344
+ const expected = this.shared ? this.stateView[RUNNING_INDEX] : 0;
345
+ // Same-priority FIFO gate: see run().
346
+ if (this.queues[p + 3].cnt === 0 && this.#tryAcquire(p)) {
295
347
  try {
296
348
  fn(opaque);
297
349
  }
@@ -302,21 +354,38 @@ export class Scheduler extends Queue {
302
354
  }
303
355
  return true;
304
356
  }
357
+ const queue = this.queues[p + 3];
305
358
  queue.arr.push(fn, opaque);
306
359
  queue.cnt += 1;
360
+ if (queue.cnt === 1) {
361
+ this.nonEmptyMask |= 1 << queue.i;
362
+ }
307
363
  this.pending += 1;
308
364
  if (this.shared) {
309
- this.#maybeWait(this.stateView[RUNNING_INDEX]);
365
+ const fresh = this.#maybeWait(expected);
366
+ if (fresh !== -1) {
367
+ this.#schedule(fresh);
368
+ }
310
369
  }
311
370
  return false;
312
371
  }
372
+ // Park a waiter on RUNNING when this instance has queued work that only a remote
373
+ // release can unblock. Returns -1 when parked (or when waiting is not applicable:
374
+ // non-shared, nothing pending, already parked, cap 0); otherwise returns a fresh
375
+ // RUNNING value the caller must re-dispatch with (#schedule) instead of parking.
376
+ //
377
+ // We park even while local tasks are running: a local release does drive
378
+ // #schedule directly, but capacity freed by a REMOTE release is only ever
379
+ // observed through this waiter — refusing to park while this.running > 0 left
380
+ // the backlog serialized behind the slowest local task (and hung forever behind
381
+ // an unbounded one) while free shared slots sat idle.
313
382
  #maybeWait(expected) {
314
- if (!this.shared || this.running > 0 || this.pending === 0 || this.#waitPromise) {
315
- return;
383
+ if (!this.shared || this.pending === 0 || this.#waitPromise) {
384
+ return -1;
316
385
  }
317
386
  // No point waiting when global cap is 0 — value can never drop to enable dispatch.
318
387
  if (this.#max === 0) {
319
- return;
388
+ return -1;
320
389
  }
321
390
  // Bump WAITERS BEFORE waitAsync so any concurrent release that already
322
391
  // decremented RUNNING will observe us — a release that misses our increment
@@ -325,6 +394,18 @@ export class Scheduler extends Queue {
325
394
  // pair the decrement in the .then; the cost is one wasted atomic pair on
326
395
  // the rare not-equal path.
327
396
  Atomics.add(this.stateView, WAITERS_INDEX, 1);
397
+ // ABA guard: `expected` predates the caller's failed capacity check. A remote
398
+ // release in between skipped notify (WAITERS was 0) — and if a remote acquire
399
+ // then restored RUNNING to exactly `expected`, waitAsync would park on a value
400
+ // that already changed, with the missed release's capacity unconsumed. Re-read
401
+ // AFTER the WAITERS increment: from this point any release will notify us, so
402
+ // an unchanged read is safe to park on, and a changed read means capacity may
403
+ // be free — hand it back to the caller for a dispatch pass instead of parking.
404
+ const current = this.stateView[RUNNING_INDEX];
405
+ if (current !== expected) {
406
+ Atomics.sub(this.stateView, WAITERS_INDEX, 1);
407
+ return current;
408
+ }
328
409
  // Atomics.waitAsync does not keep the Node event loop alive on its own. Callers
329
410
  // with idle workers (running===0 and tasks queued) need an external keep-alive
330
411
  // (their own setTimeout, setInterval, HTTP server, etc.) until notify wakes us.
@@ -332,18 +413,28 @@ export class Scheduler extends Queue {
332
413
  this.#waitPromise = (async ? value : Promise.resolve(value)).then(() => {
333
414
  // If [kOnExit] already fired (Node still drains the microtask queue
334
415
  // after process.on('exit')), it has already drained WAITERS for us and
335
- // any further state mutation would corrupt shared counters.
416
+ // any further state mutation would corrupt shared counters. But we must
417
+ // forward the wakeup: Atomics.waitAsync cannot be cancelled, so a
418
+ // disposed instance's waiter stays in the (FIFO) wait set and a
419
+ // notify(1) aimed at a live waiter parked behind it would otherwise be
420
+ // swallowed here, stranding that waiter's queue forever. Re-notifying
421
+ // re-targets the wakeup to the next waiter; when none is parked it is a
422
+ // harmless no-op.
336
423
  if (this.dead) {
424
+ Atomics.notify(this.stateView, RUNNING_INDEX, 1);
337
425
  return;
338
426
  }
339
427
  Atomics.sub(this.stateView, WAITERS_INDEX, 1);
340
428
  this.#waitPromise = null;
341
429
  this.#schedule(this.stateView[RUNNING_INDEX]);
342
430
  });
431
+ return -1;
343
432
  }
344
433
  tryAcquire(priority) {
345
434
  const p = priority == null ? Queue.NORMAL : parsePriority(priority);
346
- return this.#tryAcquire(p);
435
+ // Same-priority FIFO gate (see run()): refuse a slot that work queued at this
436
+ // priority is already waiting for, mirroring Limiter.tryConsume's pending check.
437
+ return this.queues[p + 3].cnt === 0 && this.#tryAcquire(p);
347
438
  }
348
439
  #tryAcquire(priority) {
349
440
  if (this.dead) {
@@ -379,13 +470,21 @@ export class Scheduler extends Queue {
379
470
  // Hard cap on global concurrency. getNextQueue's lottery bypasses per-priority
380
471
  // limits to prevent starvation and would otherwise push running above max.
381
472
  if (running >= max) {
382
- this.#maybeWait(running);
383
- break;
473
+ // #maybeWait returns a fresh RUNNING value (instead of parking) when the
474
+ // counter changed under us — loop back and retry the dispatch with it.
475
+ running = this.#maybeWait(running);
476
+ if (running === -1) {
477
+ break;
478
+ }
479
+ continue;
384
480
  }
385
481
  const queue = this.getNextQueue(limits, running);
386
482
  if (queue == null) {
387
- this.#maybeWait(running);
388
- break;
483
+ running = this.#maybeWait(running);
484
+ if (running === -1) {
485
+ break;
486
+ }
487
+ continue;
389
488
  }
390
489
  const fn = queue.arr[queue.idx];
391
490
  queue.arr[queue.idx++] = null;
@@ -393,6 +492,7 @@ export class Scheduler extends Queue {
393
492
  queue.arr[queue.idx++] = null;
394
493
  queue.cnt -= 1;
395
494
  if (queue.cnt === 0) {
495
+ this.nonEmptyMask &= ~(1 << queue.i);
396
496
  queue.idx = 0;
397
497
  // `queue.arr = []` is faster than `arr.length = 0` in V8: truncation walks
398
498
  // the elements area to clear refs, while reassigning drops the old backing
@@ -412,10 +512,16 @@ export class Scheduler extends Queue {
412
512
  fn(opaque);
413
513
  }
414
514
  catch (err) {
415
- // Balance the counter we just incremented before propagating. this.releasing=true
416
- // so the nested release() only decrements — it won't re-enter this dispatch loop.
515
+ // Balance the counter we just incremented (this.releasing=true keeps the
516
+ // nested release() from re-entering this dispatch loop), then isolate the
517
+ // failure exactly like Limiter's drain: surface it asynchronously and keep
518
+ // dispatching. Propagating from here would abort the loop — and when the
519
+ // thrower didn't release a slot first, no future release is coming, so the
520
+ // remaining backlog (and any queued run() promises) would strand forever.
417
521
  this.release();
418
- throw err;
522
+ queueMicrotask(() => {
523
+ throw err;
524
+ });
419
525
  }
420
526
  // Re-read running after fn() in case it synchronously called release().
421
527
  // Plain Int32Array load: same soft-limit relaxation as #tryAcquire — a
@@ -463,7 +569,12 @@ export class Scheduler extends Queue {
463
569
  else {
464
570
  running = this.shared ? this.stateView[RUNNING_INDEX] : this.running;
465
571
  }
466
- this.#schedule(running);
572
+ // Skip the (non-inlined) #schedule call entirely when nothing is queued —
573
+ // measurably cheaper on the no-backlog acquire/release hot path, and
574
+ // semantically identical (#schedule with pending === 0 is a no-op).
575
+ if (this.pending !== 0) {
576
+ this.#schedule(running);
577
+ }
467
578
  };
468
579
  [Symbol.dispose]() {
469
580
  if (this.dead) {
@@ -473,6 +584,22 @@ export class Scheduler extends Queue {
473
584
  // pair the WAITERS increment of a parked waitAsync, and mark the instance dead so any
474
585
  // late notify .then microtask becomes a no-op (see the `dead` field docstring).
475
586
  this[kOnExit]();
587
+ // Reject queued run() promises so callers awaiting them fail fast instead of
588
+ // hanging forever — the dead-guard in run() only covers calls made AFTER dispose,
589
+ // not work already sitting in the queues. Bare acquire() callbacks are simply
590
+ // dropped: queued acquire work carries no completion contract to honor.
591
+ for (const queue of this.queues) {
592
+ for (let i = queue.idx; i < queue.arr.length; i += 2) {
593
+ if (queue.arr[i] === this.#runTask) {
594
+ ;
595
+ queue.arr[i + 1].reject(new Error('Scheduler is disposed'));
596
+ }
597
+ }
598
+ queue.arr = [];
599
+ queue.idx = 0;
600
+ queue.cnt = 0;
601
+ }
602
+ this.nonEmptyMask = 0;
476
603
  // Drop our reference to the parked waitAsync chain and remove the strong ref that the
477
604
  // exit registry holds, so the instance — and the .then closure capturing it — can be
478
605
  // garbage-collected without waiting for process exit. Cleanup already ran above, so
@@ -1 +1 @@
1
- {"version":3,"file":"scheduler.js","sourceRoot":"","sources":["../src/scheduler.ts"],"names":[],"m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AG,CAAC,CAAA;QACrB,sFAAsF;QACtF,qFAAqF;QACrF,oFAAoF;QACpF,wEAAwE;QACxE,IAAI,CAAC,YAAY,GAAG,IAAI,CAAA;QACxB,UAAU,CAAC,MAAM,CAAC,IAAI,CAAC,CAAA;IACzB,CAAC;CACF"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nxtedition/scheduler",
3
- "version": "4.1.10",
3
+ "version": "4.1.12",
4
4
  "type": "module",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",
@@ -32,5 +32,5 @@
32
32
  "tsd": "^0.33.0",
33
33
  "typescript": "^5.9.3"
34
34
  },
35
- "gitHead": "7c9c7457c885c644c7a1e70ef894d4727ce240d6"
35
+ "gitHead": "c9f2526dc870597de119b8ec5083f97901d4a2e2"
36
36
  }