Skip to content

fix(OUT-4109): await SWR mutate refetches and enrich fetcher errors - #1437

Closed
cursor[bot] wants to merge 2 commits into
mainfrom
cursor/out-4109-cursor-automated-triage-response-09f9
Closed

fix(OUT-4109): await SWR mutate refetches and enrich fetcher errors#1437
cursor[bot] wants to merge 2 commits into
mainfrom
cursor/out-4109-cursor-automated-triage-response-09f9

Conversation

@cursor

@cursor cursor Bot commented Aug 24, 2026

Copy link
Copy Markdown
Contributor

Sentry Error: An error occurred while fetching the data. is a src/utils/fetcher.ts throw escaping as an unhandled rejection: SWR mutate() promises weren't awaited or caught, so the surrounding try/catch never saw them. OUT-4109 — also covers OUT-4107 (same root cause; #1436 can be closed).

What to look at:

  • src/utils/fetcher.ts — the error now carries the request path, not the URL. The URL's query string holds the live Copilot session token, and the first pass of this PR would have shipped it to Sentry on every failed fetch. It also attaches status, which swr-config.ts:onErrorRetry already reads to skip retrying 404s — that check was dead until now, so 404s stop being retried 3×.
  • ActivityWrapper.tsx / Subtasks.tsx / Subtemplates.tsx — two rejection paths per file: the optimistic mutate(...) (now awaited inside the existing try/catch) and the fire-and-forget debounceMutate(cacheKey) revalidation (now .catch-ed). Only the first was fixed initially.
  • Subtasks.tsx / Subtemplates.tsxhandleSubTaskCreation / handleSubtemplateCreation are now async; adding await without this broke yarn tsc.

Verified: yarn tsc, yarn lint:check (0 errors), yarn prettier:check, yarn test src/utils/fetcher.test.ts (4/4). Not verified: no manual browser run against a failing API — the optimistic rollback behaviour on error is unchanged by this diff but wasn't exercised end to end.

Await unawaited mutate() calls in ActivityWrapper, Subtasks, and
Subtemplates so post-mutation fetcher() failures are caught by existing
try/catch blocks instead of surfacing as unhandled promise rejections.

Enrich fetcher errors with HTTP status, URL, and response body snippet
for actionable Sentry events.

Co-authored-by: Neil Raina <[email protected]>
@linear-code

linear-code Bot commented Aug 24, 2026

Copy link
Copy Markdown

OUT-4109

@vercel

vercel Bot commented Aug 24, 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 Aug 26, 2026 3:20am

Request Review

… from fetcher errors

The unawaited mutate() fix missed the fire-and-forget debounceMutate(cacheKey)
paths, which reject the same way when revalidation fails, and it made two
non-async handlers await, so the branch did not typecheck.

The enriched error also embedded the full URL, which carries the Copilot
session token — that would have shipped a live credential to Sentry on every
failed fetch. Log the path only and attach the status, which swr-config's
onErrorRetry already reads to skip retrying 404s.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01Y4tF84tzJW7Bo1DehsDX22
@vercel

vercel Bot commented Aug 26, 2026

Copy link
Copy Markdown
Contributor

Deployment failed for project tasks-app 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

@priosshrsth

Copy link
Copy Markdown
Collaborator

Superseded by #1439, which keeps just the rejection handling.

Dropping from this branch: the fetcher.ts error enrichment embedded the full request URL, whose query string carries the live Copilot session token — that would have shipped a credential to Sentry on every failed fetch. Also, the await mutate( additions here didn't compile (two non-async handlers), and the three fire-and-forget debounceMutate(cacheKey) paths reject the same way and weren't covered.

Happy to do the error-message enrichment as its own small PR later if we want these Sentry events to carry a status and path.

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