Merge timeout fix PR #1142 to stop supermemory MCP stalls#1143
Conversation
Add FETCH_TIMEOUT_MS = 30_000 constant and apply AbortSignal.timeout to all outbound fetch calls from the supermemory-mcp Durable Object: - client.ts: SDK constructor timeout + getProjects/getDocuments signals - client.ts: handleError catches AbortError/TimeoutError with friendly msg - auth.ts: validateOAuthToken fetch signal - index.ts: oauth-authorization-server proxy fetch signal Fixes stalls where downstream services (Turbopuffer/Gemini) blocked DO subrequests for minutes with no client-side timeout. Co-authored-by: Dhravya Shah <dhravya@supermemory.com>
Deploying with
|
| Status | Name | Latest Commit | Updated (UTC) |
|---|---|---|---|
| ✅ Deployment successful! View logs |
supermemory-mcp | 790f989 | Jun 22 2026, 06:05 AM |
Deploying with
|
| Status | Name | Latest Commit | Preview URL | Updated (UTC) |
|---|---|---|---|---|
| ✅ Deployment successful! View logs |
supermemory-app | 790f989 | Commit Preview URL Branch Preview URL |
Jun 22 2026, 06:07 AM |
|
Claude finished @MaheshtheDev's task in 1m 4s —— View job Reviewing PR #1143
Overview: Adds 30-second fetch timeouts across all MCP outbound requests and returns retryable 504 errors on auth stalls. Issues found: None — this looks good to ship. The previous review gaps have been addressed:
The implementation is clean and consistent:
Score: 10/10 — All identified gaps from prior reviews are fixed. No bugs, no security issues, clean logic. |
There was a problem hiding this comment.
Overview: Adds 30-second fetch timeouts to prevent MCP stalls from slow downstream services.
Issues found:
The previous review correctly identified a gap: validateApiKey() in apps/mcp/src/auth.ts:30-35 still lacks a timeout signal, while validateOAuthToken() now has one. Since handleMcpRequest() calls validateApiKey() before constructing the SupermemoryClient, API-key authenticated MCP requests can still hang indefinitely during auth — the new SDK/client timeouts never get a chance to apply.
Fix needed: Add signal: AbortSignal.timeout(30_000) to the fetch in validateApiKey(), matching the pattern used in validateOAuthToken(). Consider extracting the timeout constant to a shared location if not already done.
Everything else looks solid:
- SDK constructor timeout ✓
getProjects/getDocumentsdefault signals ✓handleErrorcatchesAbortError/TimeoutError✓- OAuth metadata proxy timeout ✓
Score: 7/10 — One auth path still exposed to the original stall bug. Once that's fixed, this is ready to ship.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 3d5579a006
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Add shared FETCH_TIMEOUT_MS, timeout both API-key and OAuth auth paths, disable SDK retries for a true 30s bound, and distinguish auth timeouts from invalid credentials so clients get 504 instead of 401.
Problem
Outbound requests from the
supermemory-mcpDurable Object toapi.supermemory.aihad no client-side timeout, causing stalls of up to ~318 seconds when downstream services (Turbopuffer, Gemini) were slow. Two code paths were affected:search,add,forget,profile) — theSupermemorySDK client was constructed without atimeoutoption.fetchcalls (getProjects,getDocuments, auth endpoints, OAuth metadata proxy) — nosignalorAbortSignalat all, meaning stalls could last indefinitely.Changes
apps/mcp/src/client.tsFETCH_TIMEOUT_MS = 30_000constanttimeout: FETCH_TIMEOUT_MSto theSupermemorySDK constructor to bound all SDK-backed callsoptions?: { signal?: AbortSignal }togetProjectsandgetDocuments, defaulting toAbortSignal.timeout(FETCH_TIMEOUT_MS)handleErrorto catchAbortError/TimeoutErrorand surface a friendly"Request to Supermemory API timed out"messageapps/mcp/src/auth.tssignal: AbortSignal.timeout(30_000)to thevalidateOAuthTokenfetch callapps/mcp/src/index.tssignal: AbortSignal.timeout(30_000)to the OAuth authorization server metadata proxy fetchAssumptions
server.tsdo not currently have a per-requestAbortSignalfrom theMcpAgent/ExecutionContext, so theoptionsparameter serves as an extension point for future use; all existing call sites pick up the 30-second default automatically.@supermemory/tools) are not caused by this change — the MCP package itself has no new type errors.Closes the latency anomaly reported in Polylane investigation
fix_ee52cb420001xem6qyi2tc7t.Session Details
(aside)to your comment to have me ignore it.