aboutsummaryrefslogtreecommitdiffstats
path: root/packages/shared/customFetch.ts
diff options
context:
space:
mode:
Diffstat (limited to 'packages/shared/customFetch.ts')
-rw-r--r--packages/shared/customFetch.ts13
1 files changed, 13 insertions, 0 deletions
diff --git a/packages/shared/customFetch.ts b/packages/shared/customFetch.ts
new file mode 100644
index 00000000..e9ac8a89
--- /dev/null
+++ b/packages/shared/customFetch.ts
@@ -0,0 +1,13 @@
+import serverConfig from "./config";
+
+// Custom fetch function with configurable timeout
+export function customFetch(
+ input: Parameters<typeof fetch>[0],
+ init?: Parameters<typeof fetch>[1],
+): ReturnType<typeof fetch> {
+ const timeout = serverConfig.inference.fetchTimeoutSec * 1000; // Convert to milliseconds
+ return fetch(input, {
+ signal: AbortSignal.timeout(timeout),
+ ...init,
+ });
+}