From 09047e30f01bf4f69bde2246d83b569e4ea8b4a4 Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Sat, 20 Jun 2026 21:37:42 +0000 Subject: [PATCH] Add 30-second request timeouts to SupermemoryMCP client calls - Set timeout: 30_000 on the Supermemory SDK constructor so all SDK method calls (add, memories.forget, search.memories, profile) time out after 30 s instead of hanging indefinitely. - Add signal: AbortSignal.timeout(30_000) to the two manual fetch helpers getProjects and getDocuments. - Handle AbortError / TimeoutError in handleError so a timed-out request surfaces a clear message instead of propagating an unhandled exception into the Durable Object. Co-authored-by: Dhravya Shah --- apps/mcp/src/client.ts | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/apps/mcp/src/client.ts b/apps/mcp/src/client.ts index ee35fcf1..1a405979 100644 --- a/apps/mcp/src/client.ts +++ b/apps/mcp/src/client.ts @@ -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 (