Skip to content

Add fetch timeout and caching to supermemory-docs-mintlify proxy worker#1179

Draft
Dhravya wants to merge 2 commits into
mainfrom
cursor/polylane-autofix-add-fetch-timeout-and-caching-to-supermemory-docs-mintlify-proxy-worker-9c26
Draft

Add fetch timeout and caching to supermemory-docs-mintlify proxy worker#1179
Dhravya wants to merge 2 commits into
mainfrom
cursor/polylane-autofix-add-fetch-timeout-and-caching-to-supermemory-docs-mintlify-proxy-worker-9c26

Conversation

@Dhravya

@Dhravya Dhravya commented Jun 30, 2026

Copy link
Copy Markdown
Member

Summary

Creates a new Cloudflare Worker app at apps/docs-proxy/ to replace the existing supermemory-docs-mintlify dashboard-deployed worker. The previous worker was a plain reverse proxy to https://supermemory.mintlify.dev with no timeout or caching, causing critical latency anomalies (P99 wall time reaching 836 seconds / ~14 minutes) when Mintlify is slow.

Changes

New files:

  • apps/docs-proxy/src/index.ts — Worker implementation
  • apps/docs-proxy/wrangler.jsonc — Wrangler config (name: supermemory-docs-mintlify)
  • apps/docs-proxy/package.json — Package manifest (@repo/docs-proxy)
  • apps/docs-proxy/tsconfig.json — TypeScript config for Cloudflare Workers

Key improvements

Feature Before After
Fetch timeout None (hangs indefinitely) 10-second AbortController timeout → 504
Caching None Cache API: GET responses cached 5 min (max-age=300)
Error UX Upstream error propagated User-friendly "temporarily unavailable" on timeout

Implementation notes

  • Uses caches.default (Cloudflare Cache API) — only caches successful GET responses with response.ok
  • AbortController timeout fires after 10 seconds; caught AbortError returns 504
  • Proxies original method, headers, and body to https://supermemory.mintlify.dev + original path + query string
  • No bindings (no KV, D1, R2, DO, or service bindings) — zero-config deploy

Validation

  • tsc --noEmit: passes with zero errors
  • wrangler deploy --dry-run: "No bindings found. --dry-run: exiting now." (1.44 KiB upload)

Deployment

This app is deployed independently — not wired into Turbo CI. To deploy:

cd apps/docs-proxy
wrangler deploy --minify

Assumptions

  • The existing supermemory-docs-mintlify worker (dashboard-deployed) should be replaced/updated to point to this worker source after deployment
  • 10-second timeout and 5-minute cache TTL are reasonable defaults; can be tuned via constants at the top of src/index.ts
  • No routes/custom domain config added to wrangler.jsonc — assumes the existing worker already has the route configured in the Cloudflare dashboard
Open in Web Open in Cursor 

Session Details

  • Session: View Session
  • Requested by: Unknown
  • Address comments on this PR. Add (aside) to your comment to have me ignore it.

Creates apps/docs-proxy/ - a new Cloudflare Worker that replaces the
supermemory-docs-mintlify dashboard-deployed worker.

Key improvements over the previous worker:
- AbortController with 10-second timeout prevents indefinite hangs
  when Mintlify is slow (previous P99 reached 836 seconds)
- Cache API (caches.default) caches successful GET responses for
  5 minutes to reduce upstream load and improve response times
- Returns 504 with a user-friendly message on timeout

Worker proxies all requests to https://supermemory.mintlify.dev
preserving original path, query string, method, headers, and body.

Co-authored-by: Dhravya Shah <dhravya@supermemory.com>
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Jun 30, 2026

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 9b85bb2 Jun 30 2026, 04:05 AM

The project uses no-semicolons style per Biome configuration.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Jun 30, 2026

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 9b85bb2 Commit Preview URL

Branch Preview URL
Jun 30 2026, 04:07 AM

@vorflux vorflux Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Reviewed — found 2 issues.


Review with Vorflux

const timeoutId = setTimeout(() => controller.abort(), FETCH_TIMEOUT_MS)

try {
const proxyRequest = new Request(proxyUrl, request)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

new Request(proxyUrl, request) forwards all headers from the first-party request to the Mintlify upstream, including sensitive headers such as Cookie or Authorization. If this worker serves a Supermemory docs URL, domain-scoped cookies or client auth headers could be leaked upstream. Please construct a sanitized upstream header set and explicitly drop sensitive and hop-by-hop headers.

@@ -0,0 +1,49 @@
const UPSTREAM_BASE = "https://supermemory.mintlify.dev"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This new file is not Biome-formatted, and repo CI runs Biome on changed files. The delegated check reported biome ci fails with File content differs from formatting output; please format the file so CI passes.

@vorflux

vorflux Bot commented Jun 30, 2026

Copy link
Copy Markdown
Contributor

Testing completed for PR #1179.

Functional verification passed for the new docs proxy worker.

Commands/checks reported by the testing subagent:

  • bunx tsc --noEmit -p apps/docs-proxy/tsconfig.json — PASS
  • cd apps/docs-proxy && bunx wrangler deploy --dry-run --outdir /tmp/pr1179-docs-proxy-dryrun-final — PASS
  • Started local worker with bunx wrangler dev --ip 127.0.0.1 --port 8787 — PASS
  • Live proxy check: upstream https://supermemory.mintlify.dev/docs final status 200 and local http://127.0.0.1:8787/docs final status 200 on repeated requests — PASS
  • One-off harness validated path/query preservation and cache population, repeated GET cache serving with Cache-Control: public, max-age=300, POST bypassing cache, and timeout returning 504 fallback — PASS

Coverage note from testing: there are no committed tests for the new worker behavior; the cache, timeout, and proxy behavior were validated with a one-off harness rather than checked-in tests.

No screenshots or recordings were applicable because there were no UI changes.

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