@@ -41,6 +41,46 @@ Tests are also a good place to know how the library works internally: [test](tes
4141
4242See [ Configuration.ts] ( src/Typesense/Configuration.ts ) for a list of all client configuration options.
4343
44+ ### Request Timeouts and Abort Signals
45+
46+ The client supports both global timeout configuration and per-request abort signals:
47+
48+ #### Global Timeout Configuration
49+
50+ ``` javascript
51+ const client = new Typesense.Client ({
52+ nodes: [{ host: " localhost" , port: " 8108" , protocol: " http" }],
53+ apiKey: " xyz" ,
54+ connectionTimeoutSeconds: 30 , // 30 second timeout for all requests
55+ });
56+ ```
57+
58+ #### Per-Request Abort Signals
59+
60+ ``` javascript
61+ // Search with 5-second timeout
62+ const controller = new AbortController ();
63+ setTimeout (() => controller .abort (), 5000 );
64+
65+ const results = await client .collections (" books" ).documents ().search (
66+ {
67+ q: " *" ,
68+ query_by: " title" ,
69+ },
70+ { abortSignal: controller .signal },
71+ );
72+
73+ // Collections with 2-second timeout
74+ const collectionsController = new AbortController ();
75+ setTimeout (() => collectionsController .abort (), 2000 );
76+
77+ const collections = await client .collections ().retrieve ({
78+ abortSignal: collectionsController .signal ,
79+ });
80+ ```
81+
82+ ** Note** : The ` import() ` operation doesn't support abort signals or timeout configuration as it's designed to run to completion.
83+
4484### Examples
4585
4686Here are some examples with inline comments that walk you through how to use the client: [ doc/examples] ( doc/examples )
0 commit comments