maxpool 1.5.59 → 1.5.60
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/package.json +1 -1
- package/src/server.js +24 -1
package/package.json
CHANGED
package/src/server.js
CHANGED
|
@@ -33,6 +33,10 @@ const NETWORK_ERROR_CODES = new Set([
|
|
|
33
33
|
'ENOTFOUND', 'EAI_AGAIN', 'EPIPE', 'ECONNABORTED', 'UND_ERR_SOCKET', 'UND_ERR_HEADERS_TIMEOUT',
|
|
34
34
|
]);
|
|
35
35
|
const isNetworkCode = c => Boolean(c) && NETWORK_ERROR_CODES.has(c);
|
|
36
|
+
// How long a NON-STREAMING request may soak through a network blip. Short by construction:
|
|
37
|
+
// with no keepalive the client's hard 300s floor applies, so we must error first.
|
|
38
|
+
const NETWORK_SOAK_NONSTREAM_MS = Math.max(5_000,
|
|
39
|
+
Number(process.env.MAXPOOL_NETWORK_SOAK_NONSTREAM_MS) || 45_000);
|
|
36
40
|
const QUEUE_KEEPALIVE = 'event: ping\ndata: {}\n\n';
|
|
37
41
|
// 240s, strictly BELOW Claude Code's hard 300s stall floor. At the old 300_000 the two
|
|
38
42
|
// timers were a dead heat and the client always won — maxpool's clock starts when a chunk
|
|
@@ -1958,7 +1962,26 @@ async function queueAndRetry(
|
|
|
1958
1962
|
// a real outage doesn't spin. A non-streaming network failure (no keepalive) still
|
|
1959
1963
|
// fails fast — it would die on the client's own timeout anyway.
|
|
1960
1964
|
if (cause === 'proxy') return false;
|
|
1961
|
-
if (cause === 'network' &&
|
|
1965
|
+
if (cause === 'network' && !canQueueBufferedBody) return false;
|
|
1966
|
+
// NETWORK SOAK, hard-bounded. A brief connectivity blip should not throw away a turn —
|
|
1967
|
+
// but an unbounded soak is worse than a fast error (it presents as a hang, which is the
|
|
1968
|
+
// failure mode the user explicitly fears). So a network-caused hold carries its OWN
|
|
1969
|
+
// absolute deadline, stamped once and NEVER reset by a re-queue, independent of the
|
|
1970
|
+
// per-attempt queue window. Past it, we stop soaking and return the honest error.
|
|
1971
|
+
//
|
|
1972
|
+
// Non-streaming gets a short budget: it has no keepalive, so the client's hard 300s
|
|
1973
|
+
// floor applies with nothing resetting it — we must give up well before that so the user
|
|
1974
|
+
// sees a real message instead of a client-side timeout.
|
|
1975
|
+
if (cause === 'network') {
|
|
1976
|
+
const budgetMs = requestInfo.stream
|
|
1977
|
+
? Math.max(60_000, Number(queueConfig.networkMaxWaitMs) || 120_000)
|
|
1978
|
+
: NETWORK_SOAK_NONSTREAM_MS;
|
|
1979
|
+
requestInfo.networkSoakDeadline ||= Date.now() + budgetMs;
|
|
1980
|
+
if (Date.now() >= requestInfo.networkSoakDeadline) {
|
|
1981
|
+
console.log(`[Maxpool] Network soak budget spent (${Math.round(budgetMs / 1000)}s) — returning the connection error instead of holding longer`);
|
|
1982
|
+
return false;
|
|
1983
|
+
}
|
|
1984
|
+
}
|
|
1962
1985
|
|
|
1963
1986
|
const maxWaitMs = Math.max(0, Number(queueConfig.maxWaitMs) || 0);
|
|
1964
1987
|
const autoMaxWaitMs = queueConfig.autoMaxWaitMs == null
|