maxpool 1.24.35 → 1.24.36

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 +24 -27
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "maxpool",
3
- "version": "1.24.35",
3
+ "version": "1.24.36",
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
@@ -1935,7 +1935,7 @@ function isContextLengthError(errorBody) {
1935
1935
  return /exceeded model token limit|maximum context length|context length exceeded|context window (?:size )?(?:exceeded|too)|prompt is too long|input is too long|reduce the length of|too many (?:input )?tokens|request too large/i.test(errorBody);
1936
1936
  }
1937
1937
 
1938
- export const __serverTest = { directiveOnlySystemMessages, rewriteBodyForAccount, sanitizeBlocksForProvider, reanchorOrphanedSystemMessages, unavailableMessage, computeQueueWindowMs, isRetriableUpstreamStatus, classifyEffortRejection, repairEffort, isCapacitySignalStatus, isStrippableThinkingBlock, stripForeignThinkingBlocks, parseRejectedBlockPath, stripRejectedBlockClass, peekRejectedBlockType, describeRejectedBlock, headerValue, getMaxpoolProfile, ensureQueueHeartbeat, clearQueueHeartbeat, commitStreamGraceHeartbeat, describeRequest, classifyRateLimit, detectTranscriptOrigin, isAnthropicIncompatBody, isContextLengthError, isProviderParamRejection, describeBodyShape, streamResponse, startIdleRequestReaper, normalizeModelEcho, classifyHeldStreamPrefix };
1938
+ export const __serverTest = { directiveOnlySystemMessages, rewriteBodyForAccount, sanitizeBlocksForProvider, reanchorOrphanedSystemMessages, unavailableMessage, computeQueueWindowMs, waitForAvailableRoute, isRetriableUpstreamStatus, classifyEffortRejection, repairEffort, isCapacitySignalStatus, isStrippableThinkingBlock, stripForeignThinkingBlocks, parseRejectedBlockPath, stripRejectedBlockClass, peekRejectedBlockType, describeRejectedBlock, headerValue, getMaxpoolProfile, ensureQueueHeartbeat, clearQueueHeartbeat, commitStreamGraceHeartbeat, describeRequest, classifyRateLimit, detectTranscriptOrigin, isAnthropicIncompatBody, isContextLengthError, isProviderParamRejection, describeBodyShape, streamResponse, startIdleRequestReaper, normalizeModelEcho, classifyHeldStreamPrefix };
1939
1939
 
1940
1940
  async function readErrorBody(upstreamRes, limitBytes = 64 * 1024) {
1941
1941
  if (!upstreamRes.body) return '';
@@ -2715,30 +2715,23 @@ async function queueAndRetry(
2715
2715
  // terminal (disabled / error / auth-dead)". This is what stops an indefinite
2716
2716
  // hold from silently hanging every session when something is actually broken
2717
2717
  // (all accounts logged out, the only healthy account removed, etc.).
2718
- const retryAfterMs = retryPlan.retryAfterMs;
2719
- if (!Number.isFinite(retryAfterMs) || retryAfterMs > queueWindowMs) {
2720
- // FINITE-but-BEYOND-WINDOW (2026-10-12, "they should have just waited"): a
2721
- // STREAMING request with a known reset 1h out used to instant-429 here for the
2722
- // whole wait (measured 75 min, 08:13–09:34Z) while sessions burned their CLI
2723
- // retry budgets and some died entirely. Hold the stream for the window with
2724
- // the heartbeat keeping the client alive, then end with the retriable error —
2725
- // the client re-enters and the hold chains window-by-window until the reset
2726
- // lands. Non-streaming requests keep the fast error (no heartbeat = the hold
2727
- // would die on the client's idle timeout anyway).
2728
- // Capacity-class causes (concurrency cap, momentary saturation) are NOT
2729
- // chained: their "reset" is a re-poll guess, not a scheduled quota reset, and
2730
- // the capacity window exists precisely to shed that load (the soft-deadlock
2731
- // guard — pinned at cap forever must 429 within the window, never spin).
2732
- // Only quota-class resets (a scheduled 5h/weekly rollover) chain.
2733
- // Keyed on WHAT the reset is (retryPlan.cause), never on the caller's coarse label:
2734
- // the failover path calls with cause='capacity' even when the plan is a scheduled
2735
- // quota rollover, which wrongly lost the chain (red-team 2026-10-12, finding 3).
2736
- if (requestInfo.stream && queueWindowMs > 0 && Number.isFinite(retryAfterMs)
2737
- && !CAPACITY_CLASS_RETRY_CAUSES.has(retryPlan.cause)) {
2738
- requestInfo.queueHoldChain = true;
2739
- } else {
2740
- return finishQueuedStreamIfNeeded(res, requestInfo, honestMessage);
2741
- }
2718
+ const retryAfterMs = retryPlan.retryMs ?? retryPlan.retryAfterMs;
2719
+ // ALWAYS HOLD FIRST (owner 2026-10-28: "zero reason to drop those requests… even
2720
+ // when I'm out of accounts completely, I buy new ones"). The old oracle errored
2721
+ // fast whenever no FINITE scheduled reset existed (no_eligible_route,
2722
+ // weekly_reset_unknown, reset beyond window) — but recovery does not need a
2723
+ // schedule: config auto-sync adopts a newly bought account in ~15s, and a sibling
2724
+ // completing frees a slot in seconds; hasAvailableRoute polls both every tick.
2725
+ // So: hold the FULL window regardless of the plan, and only at expiry end with
2726
+ // the ≤60s-retriable 429 (clientRetryAfterSeconds caps the header), which the
2727
+ // CLI obeys silently — that IS the chaining mechanism, for streams and
2728
+ // non-streams alike. Windows stay hard-capped at the client's own ceilings
2729
+ // (25m stream / 5m non-stream), so nothing can hang past what the client
2730
+ // survives. queueHoldChain is now purely informational in the log line.
2731
+ if (queueWindowMs > 0 && Number.isFinite(retryAfterMs)
2732
+ && retryAfterMs > queueWindowMs
2733
+ && !CAPACITY_CLASS_RETRY_CAUSES.has(retryPlan.cause)) {
2734
+ requestInfo.queueHoldChain = true;
2742
2735
  }
2743
2736
 
2744
2737
  requestInfo.queueStartedAt ||= Date.now();
@@ -2894,8 +2887,12 @@ async function waitForAvailableRoute(req, res, accountManager, requestInfo, queu
2894
2887
  // removed, or the reset is unknown → retryAfterMs Infinity), stop holding
2895
2888
  // and error fast instead of spinning to the 7d ceiling. Hold is valid only
2896
2889
  // while ≥1 eligible route has a finite, known reset.
2897
- const plan = accountManager.nextRetryForRequest?.(requestInfo, new Set());
2898
- if (plan && plan.cause !== 'available' && !Number.isFinite(plan.retryAfterMs)) return false;
2890
+ // NOTE (owner 2026-10-28, queue-never-fail): the old non-finite-plan bail is
2891
+ // GONE. hasAvailableRoute above is checked every tick and returns true the
2892
+ // moment a route exists — including one created by config auto-sync adopting
2893
+ // a newly added account, which nextRetryForRequest cannot foresee. The
2894
+ // window (hard-capped at the client ceilings) bounds the poll; expiry hands
2895
+ // back a ≤60s-retriable 429 the client retries silently.
2899
2896
 
2900
2897
  const remaining = maxWaitMs - (Date.now() - startedAt);
2901
2898
  // Jitter the poll so a synchronized weekly-reset event doesn't re-align