Merge timeout additions for supermemory-mcp#1144
Conversation
- Pass explicit timeout: 30_000 to the Supermemory SDK constructor so all
SDK-backed calls (search, add, forget, profile) are bounded to 30 seconds
- Add AbortSignal.timeout(FETCH_TIMEOUT_MS) to the manual fetch calls in
getProjects() and getDocuments() which had no timeout before
- Accept an optional { signal?: AbortSignal } argument on both methods so
callers can thread a request-scoped signal when one is available
- Catch AbortError / TimeoutError in handleError() and surface a friendly
'Request to Supermemory API timed out' message instead of an opaque crash
- Follow existing codebase convention (FETCH_TIMEOUT_MS constant, same value
used in apps/api/src/services/extraction/extractors/image.ts)
Co-authored-by: Dhravya Shah <dhravya@supermemory.com>
|
Claude finished @Dhravya's task in 1m 38s —— View job PR Review: Timeout additions for supermemory-mcp
Overview: Adds 30-second request timeouts to all outbound fetch calls in the MCP server to prevent cascading failures from stalled external services. Issues found: None — this looks good to ship. The implementation is clean and follows existing patterns:
The optional Score: 10/10 |
Deploying with
|
| Status | Name | Latest Commit | Updated (UTC) |
|---|---|---|---|
| ✅ Deployment successful! View logs |
supermemory-mcp | c9376da | Jun 20 2026, 02:15 PM |
Deploying with
|
| Status | Name | Latest Commit | Preview URL | Updated (UTC) |
|---|---|---|---|---|
| ✅ Deployment successful! View logs |
supermemory-app | c9376da | Commit Preview URL Branch Preview URL |
Jun 20 2026, 02:16 PM |
There was a problem hiding this comment.
Overview: Adds 30-second request timeouts to all outbound fetch calls in the MCP server to prevent cascading failures from stalled external services.
Issues found: None — this looks good to ship.
The implementation is clean and follows the existing patterns in the codebase:
- SDK-level timeout via constructor option ✓
- Manual fetch timeouts via
AbortSignal.timeout()✓ - Proper error handling for
AbortError/TimeoutErrorin the centralizedhandleErrormethod ✓ - Consistent 30s timeout matching the pattern in
apps/api/src/services/extraction/extractors/image.ts✓
The optional signal parameter in getProjects/getDocuments provides a sensible extension point while maintaining safe defaults.
Score: 10/10
Problem
Outbound requests from the
supermemory-mcpCloudflare Worker/Durable Object toapi.supermemory.aiand the OAuth metadata endpoint had no client-side timeouts. During a critical incident, external vector/AI calls (Turbopuffer, Gemini) stalled, causing Durable Object subrequests to block for minutes, which propagated via jsrpc resulting in P99 wall times of ~150–340s and thousands of jsrpc errors on thesupermemoryCloudflare Worker.Three separate code paths were unguarded:
search,add,forget,profile) —SupermemoryClientconstructedSupermemorySDK without atimeoutoption.fetchcalls (getProjects,getDocuments) — nosignalorAbortSignalat all.validateOAuthTokeninauth.ts) — session-check fetch had no timeout./.well-known/oauth-authorization-serverinindex.ts) — no timeout.Changes
apps/mcp/src/client.tsFETCH_TIMEOUT_MS = 30_000constant.timeout: FETCH_TIMEOUT_MStoSupermemorySDK constructor.AbortSignal.timeout(FETCH_TIMEOUT_MS)togetProjectsandgetDocumentsfetch calls (with optional caller-supplied signal extension point).handleError: catchAbortError/TimeoutErrorand surface a friendly"Request to Supermemory API timed out"message.apps/mcp/src/auth.tssignal: AbortSignal.timeout(30_000)to thevalidateOAuthTokensession-check fetch.apps/mcp/src/index.ts{ signal: AbortSignal.timeout(30_000) }to the OAuth authorization server metadata fetch.Assumptions
apps/api/src/services/extraction/extractors/image.ts).cursor/polylane-autofix-add-request-timeouts-to-supermemory-mcp-client-calls-dbc1), which contains the same commits. This PR supersedes Add request timeouts to Supermemory MCP client calls #1142.supermemory-mcpexists in.github/workflows/— deployment is manual viawrangler deployinapps/mcp/. After merge, a manualwrangler deploy(or equivalent CD step) is required to ship these changes to the Cloudflare Worker.tsc --noEmitOOMed on the CI VM (memory constraint), but the changes are syntactically and semantically valid —AbortSignal.timeout()returnsAbortSignal, and the Fetch APIsignaloption acceptsAbortSignal. Pre-existing type issues in unrelated packages are not introduced by this change.Validation
After merge, the commits
f9369d5eandc9376da3will be onmain. Runbun run deployinapps/mcp/with valid Cloudflare credentials to deploy.