From dd53ccb9624e719d019a8fe29fcd66415c1b1528 Mon Sep 17 00:00:00 2001 From: Mohamed Bassem Date: Wed, 20 Aug 2025 15:57:34 +0300 Subject: deps: Upgrade expo & nextjs to react 19 (#1565) * Attempt to upgrade expo 53 * Attempt upgrade nextjs * Fix a bunch of peer deps * upgrade some docs deps * fix typecheck * update the shadcn calendar component * more fixes * more fixes * revert ollama upgrade * update react version to use carets * remove react-select from landing * fix the typescript error caused by customFetch * upgrade the new grid user setting to nextjs 15 * mobile: enable react canary to support react 19.1 * upgrade react native menu * fix navigation context error --- packages/shared/customFetch.ts | 31 +++++++++++++++++++++---------- 1 file changed, 21 insertions(+), 10 deletions(-) (limited to 'packages/shared/customFetch.ts') diff --git a/packages/shared/customFetch.ts b/packages/shared/customFetch.ts index e9ac8a89..18b4e133 100644 --- a/packages/shared/customFetch.ts +++ b/packages/shared/customFetch.ts @@ -1,13 +1,24 @@ import serverConfig from "./config"; -// Custom fetch function with configurable timeout -export function customFetch( - input: Parameters[0], - init?: Parameters[1], -): ReturnType { - const timeout = serverConfig.inference.fetchTimeoutSec * 1000; // Convert to milliseconds - return fetch(input, { - signal: AbortSignal.timeout(timeout), - ...init, - }); +// Generic fetch function type that works across environments +type FetchFunction = ( + input: RequestInfo | URL | string, + init?: RequestInit, +) => Promise; + +// Factory function to create a custom fetch with timeout for any fetch implementation +export function createCustomFetch(fetchImpl: FetchFunction = globalThis.fetch) { + return function customFetch( + input: Parameters[0], + init?: Parameters[1], + ): ReturnType { + const timeout = serverConfig.inference.fetchTimeoutSec * 1000; // Convert to milliseconds + return fetchImpl(input, { + signal: AbortSignal.timeout(timeout), + ...init, + }); + }; } + +// Default export for backward compatibility - uses global fetch +export const customFetch = createCustomFetch(); -- cgit v1.2.3-70-g09d2