Skip to content

Short-circuit detail page HEAD probes#1286

Open
cursor[bot] wants to merge 4 commits into
mainfrom
cursor/OUT-3812-cursor-automated-triage-response-b1cc
Open

Short-circuit detail page HEAD probes#1286
cursor[bot] wants to merge 4 commits into
mainfrom
cursor/OUT-3812-cursor-automated-triage-response-b1cc

Conversation

@cursor

@cursor cursor Bot commented Jun 3, 2026

Copy link
Copy Markdown
Contributor

Changes

  • Added a Next proxy handler for /detail/:task_id/:user_type that returns an empty 200 with Cache-Control: no-store for HEAD requests.
  • Left non-HEAD requests on the normal route path.
  • Added focused Jest coverage for HEAD short-circuiting and GET pass-through behavior.

Testing Criteria

  • yarn test src/proxy.test.ts --runInBand passes.
  • yarn lint:check passes with existing warnings only.
  • yarn tsc --noEmit still fails on the known pre-existing src/icons/index.ts SVG module declaration errors.
  • Runtime check with PORT=3012 yarn dev: curl -i -X HEAD "http://localhost:3012/detail/92149834-0854-483b-bd14-2bed91d1182a/cu?token=test-token" returns HTTP/1.1 200 OK and cache-control: no-store without compiling/rendering /detail/[task_id]/[user_type].
  • Runtime check with GET to the same route shape still renders through the detail route (200, existing invalid-token UI), confirming the proxy is scoped to HEAD.

resolves OUT-3802 OUT-3802: TypeError: fetch failed

Notes

  • Sentry TASKS-8J shows production HEAD requests to /detail/[task_id]/[user_type] reaching TasksService.getTraversalPath, then failing when Prisma cannot reach the Supabase pooler. This PR prevents low-value HEAD probes from invoking detail-page DB work.

Impact & Surface Area of Change

  • Affects only HEAD requests matching /detail/:task_id/:user_type.
  • GET/POST/browser detail flows should remain on the existing route behavior.
Open in Web View Automation 

Co-authored-by: Neil Raina <makeitraina@users.noreply.github.com>
@linear-code

linear-code Bot commented Jun 3, 2026

Copy link
Copy Markdown

OUT-3812

OUT-3802

@vercel

vercel Bot commented Jun 3, 2026

Copy link
Copy Markdown
Contributor

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
tasks-app Ready Ready Preview, Comment Jun 15, 2026 3:43am

Request Review

@priosshrsth priosshrsth marked this pull request as ready for review June 11, 2026 10:07
@vercel

vercel Bot commented Jun 11, 2026

Copy link
Copy Markdown
Contributor

Deployment failed with the following error:

Deploying Serverless Functions to multiple regions is restricted to the Pro and Enterprise plans.

Learn More: https://vercel.link/multiple-function-regions

@greptile-apps

greptile-apps Bot commented Jun 11, 2026

Copy link
Copy Markdown

Greptile Summary

This PR adds a Next.js 16 proxy handler (src/proxy.ts) that intercepts requests matching /detail/:task_id/:user_type and returns an immediate 200 Cache-Control: no-store for HEAD method requests, preventing those probes from reaching the Prisma/Supabase stack that was triggering Sentry TASKS-8J errors. GET and all other methods are passed through unchanged via NextResponse.next().

  • src/proxy.ts: Correctly short-circuits HEAD requests with a null-body 200 response and Cache-Control: no-store; all other methods fall through to the existing route handler via NextResponse.next().
  • src/proxy.test.ts: Covers the HEAD short-circuit (status + header) and GET pass-through paths; the x-middleware-next internal-header assertion and the unsafe buildRequest cast were already flagged in earlier review threads.

Confidence Score: 5/5

Safe to merge — the change is narrowly scoped to HEAD requests on a single route and does not alter GET/POST or any existing page rendering logic.

The proxy logic is correct: HEAD returns a well-formed null-body 200 with no-store, and all other methods are forwarded untouched. The matcher pattern is valid Next.js 16 syntax, the file is placed correctly under src/, and the jest config uses nextJest so NextResponse is available without manual mocking. The test-file issues raised in prior threads (internal header assertion, unsafe cast) are code quality nits that do not affect production behavior.

No files require special attention. src/proxy.test.ts has minor test-quality issues already noted in prior review threads.

Important Files Changed

Filename Overview
src/proxy.ts Adds a Next.js 16 proxy handler that short-circuits HEAD requests to /detail/:task_id/:user_type with a 200/no-store response, passing all other methods through to the route handler. Logic is correct; matcher syntax and NextResponse usage are sound.
src/proxy.test.ts Tests HEAD short-circuit (status + Cache-Control) and GET pass-through. The GET assertion relies on the internal x-middleware-next header (already flagged), and the buildRequest cast is unsafe (already flagged); otherwise coverage is focused and correct.

Sequence Diagram

sequenceDiagram
    participant Client
    participant Proxy as src/proxy.ts (Next.js 16 Proxy)
    participant Route as /detail/[task_id]/[user_type]
    participant DB as Supabase / Prisma

    Client->>Proxy: HEAD /detail/:task_id/:user_type
    Proxy-->>Client: 200 OK, Cache-Control: no-store (no body)

    Client->>Proxy: GET /detail/:task_id/:user_type
    Proxy->>Route: NextResponse.next() (pass-through)
    Route->>DB: TasksService.getTraversalPath(...)
    DB-->>Route: result
    Route-->>Client: 200 OK (rendered page)
Loading

Reviews (2): Last reviewed commit: "remove proxy test" | Re-trigger Greptile

Comment thread src/proxy.ts
Comment thread src/proxy.test.ts Outdated
Comment thread src/proxy.test.ts Outdated
@priosshrsth

Copy link
Copy Markdown
Collaborator

@greptileai re review this pr

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