diff --git a/packages/frontend/core/src/blocksuite/ai/provider/copilot-client.ts b/packages/frontend/core/src/blocksuite/ai/provider/copilot-client.ts index 8268ee506..0bba0a018 100644 --- a/packages/frontend/core/src/blocksuite/ai/provider/copilot-client.ts +++ b/packages/frontend/core/src/blocksuite/ai/provider/copilot-client.ts @@ -273,6 +273,7 @@ export class CopilotClient { content, options, }, + timeout: 60000, }); return res.addContextFile; } diff --git a/packages/frontend/graphql/src/fetcher.ts b/packages/frontend/graphql/src/fetcher.ts index d90cfd01d..520f6363e 100644 --- a/packages/frontend/graphql/src/fetcher.ts +++ b/packages/frontend/graphql/src/fetcher.ts @@ -8,6 +8,8 @@ import type { Mutations, Queries } from './schema'; export type NotArray = T extends Array ? never : T; +export type FetchInit = RequestInit & { timeout?: number }; + export type _QueryVariables = Q['id'] extends Queries['name'] ? Extract['variables'] @@ -75,6 +77,11 @@ export type RequestOptions = QueryVariablesOption & { * @default true */ keepNilVariables?: boolean; + /** + * Request timeout in milliseconds + * @default 15000 + */ + timeout?: number; }; export type QueryOptions = RequestOptions & { @@ -169,7 +176,7 @@ function formatRequestBody({ export const gqlFetcherFactory = ( endpoint: string, - fetcher: (input: string, init?: RequestInit) => Promise = fetch + fetcher: (input: string, init?: FetchInit) => Promise = fetch ) => { const logger = new DebugLogger('GraphQL'); const gqlFetch = async ( @@ -199,6 +206,7 @@ export const gqlFetcherFactory = ( method: 'POST', headers, body: isFormData ? body : JSON.stringify(body), + timeout: options.timeout, }) ).then(async res => { if (res.headers.get('content-type')?.startsWith('application/json')) {