@j0hanz/fetch-url-mcp 1.10.21 → 1.10.22

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.
@@ -209,6 +209,8 @@ class WorkerPool {
209
209
  closed = false;
210
210
  taskIdSeq = 0;
211
211
  busyCount = 0;
212
+ draining = false;
213
+ restartBackoff = new Map();
212
214
  constructor(size, timeoutMs) {
213
215
  this.capacity =
214
216
  size === 0
@@ -418,6 +420,18 @@ class WorkerPool {
418
420
  if (target) {
419
421
  target.worker.terminate().catch(() => undefined);
420
422
  }
423
+ const attempts = this.restartBackoff.get(workerIndex) ?? 0;
424
+ this.restartBackoff.set(workerIndex, attempts + 1);
425
+ if (attempts > 0) {
426
+ const delayMs = Math.min(1000 * 2 ** (attempts - 1), 30_000);
427
+ setTimeout(() => {
428
+ if (this.closed)
429
+ return;
430
+ this.workers[workerIndex] = this.spawnWorker(workerIndex);
431
+ this.drainQueue();
432
+ }, delayMs).unref();
433
+ return;
434
+ }
421
435
  this.workers[workerIndex] = this.spawnWorker(workerIndex);
422
436
  this.drainQueue();
423
437
  }
@@ -440,6 +454,7 @@ class WorkerPool {
440
454
  const inflight = this.takeInflight(message.id);
441
455
  if (!inflight)
442
456
  return;
457
+ this.restartBackoff.delete(workerIndex);
443
458
  this.markIdle(workerIndex);
444
459
  this.resolveWorkerResult(inflight, message);
445
460
  this.drainQueue();
@@ -500,28 +515,34 @@ class WorkerPool {
500
515
  }
501
516
  }
502
517
  drainQueue() {
503
- if (this.closed || this.queue.depth === 0)
518
+ if (this.closed || this.queue.depth === 0 || this.draining)
504
519
  return;
505
- this.maybeScaleUp();
506
- for (let i = 0; i < this.workers.length; i += 1) {
507
- const slot = this.workers[i];
508
- if (slot && !slot.busy) {
509
- this.dispatchFromQueue(i, slot);
510
- if (this.queue.depth === 0)
511
- return;
520
+ this.draining = true;
521
+ try {
522
+ this.maybeScaleUp();
523
+ for (let i = 0; i < this.workers.length; i += 1) {
524
+ const slot = this.workers[i];
525
+ if (slot && !slot.busy) {
526
+ this.dispatchFromQueue(i, slot);
527
+ if (this.queue.depth === 0)
528
+ return;
529
+ }
512
530
  }
513
- }
514
- if (this.workers.length < this.capacity && this.queue.depth > 0) {
515
- const workerIndex = this.workers.length;
516
- const slot = this.spawnWorker(workerIndex);
517
- this.workers.push(slot);
518
- this.dispatchFromQueue(workerIndex, slot);
519
531
  if (this.workers.length < this.capacity && this.queue.depth > 0) {
520
- setImmediate(() => {
521
- this.drainQueue();
522
- });
532
+ const workerIndex = this.workers.length;
533
+ const slot = this.spawnWorker(workerIndex);
534
+ this.workers.push(slot);
535
+ this.dispatchFromQueue(workerIndex, slot);
536
+ if (this.workers.length < this.capacity && this.queue.depth > 0) {
537
+ setImmediate(() => {
538
+ this.drainQueue();
539
+ });
540
+ }
523
541
  }
524
542
  }
543
+ finally {
544
+ this.draining = false;
545
+ }
525
546
  }
526
547
  dispatchFromQueue(workerIndex, slot) {
527
548
  let task = this.queue.dequeue();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@j0hanz/fetch-url-mcp",
3
- "version": "1.10.21",
3
+ "version": "1.10.22",
4
4
  "mcpName": "io.github.j0hanz/fetch-url-mcp",
5
5
  "description": "A web content fetcher MCP server that converts HTML to clean, AI and human readable markdown.",
6
6
  "type": "module",