mirror of
https://github.com/HeyPuter/puter.git
synced 2026-11-25 07:09:11 +00:00
test(ai): fail CI if the SDK timeout outgrows plain fetch's timeout (#4714)
The AI vendor SDKs use plain fetch, and nodeFetchDispatcherGuard gives it a 10-minute header and body timeout. SDK_TIMEOUT_MS relies on that, but nothing linked the two values, so raising SDK_TIMEOUT_MS above 10 minutes would still be cut off at 10 with no error. The guard now exports OUTBOUND_FETCH_TIMEOUT_MS, and sdkClient.test.ts checks that SDK_TIMEOUT_MS isn't larger than it. No change in behavior.
This commit is contained in:
1 parent
35f27bfa97
commit
19590857a6
2 files changed
+8
-3
No files matched your search
@@ -18,6 +18,7 @@
|
||||
*/
|
||||
|
||||
import { describe, expect, it } from 'vitest';
|
||||
import { OUTBOUND_FETCH_TIMEOUT_MS } from '../../../../../util/nodeFetchDispatcherGuard.js';
|
||||
import {
|
||||
SDK_TIMEOUT_MS,
|
||||
sdkClientOptions,
|
||||
@@ -33,6 +34,12 @@ describe('sdkClientOptions', () => {
|
||||
expect(SDK_TIMEOUT_MS).toBe(10 * 60 * 1000);
|
||||
});
|
||||
|
||||
// Plain fetch stops waiting at the guard's timeouts, so a longer SDK
|
||||
// timeout would never be reached.
|
||||
it('fits inside the timeouts every plain fetch gets', () => {
|
||||
expect(SDK_TIMEOUT_MS).toBeLessThanOrEqual(OUTBOUND_FETCH_TIMEOUT_MS);
|
||||
});
|
||||
|
||||
it('takes a per-provider timeout', () => {
|
||||
expect(sdkClientOptions(60_000)).toEqual({
|
||||
maxRetries: 0,
|
||||
|
||||
@@ -54,7 +54,7 @@ void fetch('data:text/plain,dispatcher-guard').catch(() => {
|
||||
// claimed dispatcher to give every plain fetch a 10-minute budget instead.
|
||||
// secureFetch is unaffected: it passes its own explicit dispatchers, keeping
|
||||
// undici's tighter defaults for user-supplied URLs.
|
||||
const OUTBOUND_FETCH_TIMEOUT_MS = 10 * 60 * 1000;
|
||||
export const OUTBOUND_FETCH_TIMEOUT_MS = 10 * 60 * 1000;
|
||||
// Symbol.for so a re-imported copy of this module (fresh module registry,
|
||||
// same process) recognizes an already-wrapped dispatcher and doesn't re-wrap.
|
||||
// A set, not a marker property: compose() can return a Proxy, which would
|
||||
@@ -123,5 +123,3 @@ for (const slot of DISPATCHER_SLOTS) {
|
||||
wrappedDispatchers.add(wrapped);
|
||||
globalSlots[slot] = wrapped;
|
||||
}
|
||||
|
||||
export {};
|
||||
Reference in new issue
Block a user