mirror of
https://github.com/supermemoryai/supermemory.git
synced 2026-08-28 05:25:33 +00:00
Add request timeouts to Supermemory MCP client calls (#1146)
Co-authored-by: Cursor Agent <cursoragent@cursor.com>
This commit is contained in:
parent
4ce13cd4cf
commit
886ee692f9
2 changed files with 3493 additions and 0 deletions
3480
apps/mcp/pnpm-lock.yaml
generated
Normal file
3480
apps/mcp/pnpm-lock.yaml
generated
Normal file
File diff suppressed because it is too large
Load diff
|
|
@ -142,6 +142,7 @@ export class SupermemoryClient {
|
|||
this.client = new Supermemory({
|
||||
apiKey: bearerToken,
|
||||
baseURL: apiUrl,
|
||||
timeout: 30_000,
|
||||
})
|
||||
this.containerTag = containerTag || DEFAULT_PROJECT_ID
|
||||
}
|
||||
|
|
@ -336,6 +337,7 @@ export class SupermemoryClient {
|
|||
Authorization: `Bearer ${this.bearerToken}`,
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
signal: AbortSignal.timeout(30_000),
|
||||
})
|
||||
|
||||
if (!response.ok) {
|
||||
|
|
@ -374,6 +376,7 @@ export class SupermemoryClient {
|
|||
order: "desc",
|
||||
containerTags,
|
||||
}),
|
||||
signal: AbortSignal.timeout(30_000),
|
||||
})
|
||||
if (!response.ok) {
|
||||
throw Object.assign(new Error("Failed to fetch documents"), {
|
||||
|
|
@ -387,6 +390,16 @@ export class SupermemoryClient {
|
|||
}
|
||||
|
||||
private handleError(error: unknown): never {
|
||||
// Handle request timeout / abort
|
||||
if (
|
||||
error instanceof Error &&
|
||||
(error.name === "AbortError" || error.name === "TimeoutError")
|
||||
) {
|
||||
throw new Error(
|
||||
"Request timed out after 30 seconds. The service may be slow or unavailable. Please try again.",
|
||||
)
|
||||
}
|
||||
|
||||
// Handle network/fetch errors
|
||||
if (error instanceof TypeError) {
|
||||
if (
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue