Skip to content

Merge timeout additions for supermemory-mcp#1144

Open
Dhravya wants to merge 2 commits into
mainfrom
cursor/polylane-autofix-merge-timeout-additions-for-supermemory-mcp-a744
Open

Merge timeout additions for supermemory-mcp#1144
Dhravya wants to merge 2 commits into
mainfrom
cursor/polylane-autofix-merge-timeout-additions-for-supermemory-mcp-a744

Conversation

@Dhravya

@Dhravya Dhravya commented Jun 20, 2026

Copy link
Copy Markdown
Member

Problem

Outbound requests from the supermemory-mcp Cloudflare Worker/Durable Object to api.supermemory.ai and 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 the supermemory Cloudflare Worker.

Three separate code paths were unguarded:

  1. SDK calls (search, add, forget, profile) — SupermemoryClient constructed Supermemory SDK without a timeout option.
  2. Manual fetch calls (getProjects, getDocuments) — no signal or AbortSignal at all.
  3. Auth validation fetch (validateOAuthToken in auth.ts) — session-check fetch had no timeout.
  4. OAuth metadata fetch (/.well-known/oauth-authorization-server in index.ts) — no timeout.

Changes

apps/mcp/src/client.ts

  • Add FETCH_TIMEOUT_MS = 30_000 constant.
  • Pass timeout: FETCH_TIMEOUT_MS to Supermemory SDK constructor.
  • Add AbortSignal.timeout(FETCH_TIMEOUT_MS) to getProjects and getDocuments fetch calls (with optional caller-supplied signal extension point).
  • handleError: catch AbortError / TimeoutError and surface a friendly "Request to Supermemory API timed out" message.

apps/mcp/src/auth.ts

  • Add signal: AbortSignal.timeout(30_000) to the validateOAuthToken session-check fetch.

apps/mcp/src/index.ts

  • Add { signal: AbortSignal.timeout(30_000) } to the OAuth authorization server metadata fetch.

Assumptions

  • 30 seconds is an appropriate upper bound for MCP tool calls (matches the existing constant pattern in apps/api/src/services/extraction/extractors/image.ts).
  • These changes are cherry-picked from draft PR Add request timeouts to Supermemory MCP client calls #1142 (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.
  • No deployment workflow for supermemory-mcp exists in .github/workflows/ — deployment is manual via wrangler deploy in apps/mcp/. After merge, a manual wrangler deploy (or equivalent CD step) is required to ship these changes to the Cloudflare Worker.
  • TypeScript tsc --noEmit OOMed on the CI VM (memory constraint), but the changes are syntactically and semantically valid — AbortSignal.timeout() returns AbortSignal, and the Fetch API signal option accepts AbortSignal. Pre-existing type issues in unrelated packages are not introduced by this change.

Validation

After merge, the commits f9369d5e and c9376da3 will be on main. Run bun run deploy in apps/mcp/ with valid Cloudflare credentials to deploy.

Open in Web Open in Cursor 

cursoragent and others added 2 commits June 20, 2026 14:10
- 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

claude Bot commented Jun 20, 2026

Copy link
Copy Markdown

Claude finished @Dhravya's task in 1m 38s —— View job


PR Review: Timeout additions for supermemory-mcp

  • Analyzing PR context
  • Fetching and reviewing diff
  • Checking for existing review comments
  • Reviewing code changes for bugs and security issues
  • Submitting review

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:

  • SDK-level timeout via constructor option ✓
  • Manual fetch timeouts via AbortSignal.timeout()
  • Proper error handling for AbortError/TimeoutError in centralized handleError method ✓
  • Consistent 30s timeout matching 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

@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Updated (UTC)
✅ Deployment successful!
View logs
supermemory-mcp c9376da Jun 20 2026, 02:15 PM

@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

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

@claude claude Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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/TimeoutError in the centralized handleError method ✓
  • 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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants