maxpool 1.24.20 → 1.24.21

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/server.js +23 -3
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "maxpool",
3
- "version": "1.24.20",
3
+ "version": "1.24.21",
4
4
  "description": "Multi-account Claude Code proxy with adaptive, rate-aware load balancing across Claude accounts",
5
5
  "type": "module",
6
6
  "main": "src/index.js",
package/src/server.js CHANGED
@@ -2714,7 +2714,25 @@ async function queueAndRetry(
2714
2714
  // (all accounts logged out, the only healthy account removed, etc.).
2715
2715
  const retryAfterMs = retryPlan.retryAfterMs;
2716
2716
  if (!Number.isFinite(retryAfterMs) || retryAfterMs > queueWindowMs) {
2717
- return finishQueuedStreamIfNeeded(res, requestInfo, honestMessage);
2717
+ // FINITE-but-BEYOND-WINDOW (2026-10-12, "they should have just waited"): a
2718
+ // STREAMING request with a known reset 1h out used to instant-429 here for the
2719
+ // whole wait (measured 75 min, 08:13–09:34Z) while sessions burned their CLI
2720
+ // retry budgets and some died entirely. Hold the stream for the window with
2721
+ // the heartbeat keeping the client alive, then end with the retriable error —
2722
+ // the client re-enters and the hold chains window-by-window until the reset
2723
+ // lands. Non-streaming requests keep the fast error (no heartbeat = the hold
2724
+ // would die on the client's idle timeout anyway).
2725
+ // Capacity-class causes (concurrency cap, momentary saturation) are NOT
2726
+ // chained: their "reset" is a re-poll guess, not a scheduled quota reset, and
2727
+ // the capacity window exists precisely to shed that load (the soft-deadlock
2728
+ // guard — pinned at cap forever must 429 within the window, never spin).
2729
+ // Only quota-class resets (a scheduled 5h/weekly rollover) chain.
2730
+ if (requestInfo.stream && queueWindowMs > 0 && Number.isFinite(retryAfterMs)
2731
+ && retryPlan.cause !== 'concurrency_cap' && cause !== 'capacity') {
2732
+ requestInfo.queueHoldChain = true;
2733
+ } else {
2734
+ return finishQueuedStreamIfNeeded(res, requestInfo, honestMessage);
2735
+ }
2718
2736
  }
2719
2737
 
2720
2738
  requestInfo.queueStartedAt ||= Date.now();
@@ -2741,12 +2759,14 @@ async function queueAndRetry(
2741
2759
 
2742
2760
  ctx.account = '(queued)';
2743
2761
  hooks.onRequestRouted?.(reqId, { account: '(queued)' });
2744
- console.log(`[Maxpool] ${reason}; queueing request for up to ${Math.ceil(remaining / 1000)}s (cause: ${cause}, retry: ${retryPlan.cause})`);
2762
+ // Hold-chain note: when this hold expires still-full (queueHoldChain), the
2763
+ // finishQueuedStreamIfNeeded below ends the stream with the retriable error and
2764
+ // the client re-enters — the log line makes the chaining visible.
2765
+ console.log(`[Maxpool] ${reason}; queueing request for up to ${Math.ceil(remaining / 1000)}s (cause: ${cause}, retry: ${retryPlan.cause}${requestInfo.queueHoldChain ? ', hold-chain: reset beyond window' : ''})`);
2745
2766
  ensureQueueHeartbeat(res, requestInfo, queueConfig, accountManager);
2746
2767
 
2747
2768
  const available = await waitForAvailableRoute(req, res, accountManager, requestInfo, queueConfig, remaining);
2748
2769
  if (!available) {
2749
- if (res.destroyed || req.destroyed) return true;
2750
2770
  accountManager.removeQueuedRequest?.(requestInfo);
2751
2771
  return finishQueuedStreamIfNeeded(res, requestInfo, honestMessage);
2752
2772
  }