Skip to content

OUT-4109 | Handle SWR mutate rejections instead of letting them reach Sentry - #1439

Merged
priosshrsth merged 5 commits into
mainfrom
anit/out-4109-unhandled-swr-mutate-rejections
Aug 27, 2026
Merged

OUT-4109 | Handle SWR mutate rejections instead of letting them reach Sentry#1439
priosshrsth merged 5 commits into
mainfrom
anit/out-4109-unhandled-swr-mutate-rejections

Conversation

@priosshrsth

Copy link
Copy Markdown
Collaborator

Error: An error occurred while fetching the data. is src/utils/fetcher.ts throwing inside an SWR mutate() whose promise nothing handles, so it lands in Sentry via onunhandledrejection rather than the try/catch that's already sitting right there. OUT-4109 — same root cause as OUT-4107.

Replaces #1437.

What to look at:

  • Two rejection paths per component, not one: the optimistic mutate(...) (now awaited inside the existing try/catch) and the fire-and-forget debounceMutate(cacheKey) revalidation (now .catch-ed).
  • handleSubTaskCreation / handleSubtemplateCreation had to become async for the await; both are passed as (payload) => void props, which Promise<void> satisfies.

Verified: yarn tsc, yarn lint:check (0 errors), yarn prettier:check. Not verified: no manual run against a failing API — this only changes who catches the rejection, not the optimistic rollback behaviour.

🤖 Generated with Claude Code

https://claude.ai/code/session_01Y4tF84tzJW7Bo1DehsDX22

priosshrsth and others added 4 commits August 7, 2026 10:33
…1397)

deleteLabel passed `id: currentLabel?.id` straight into label.delete, so when
findFirst matched nothing Prisma got `{ id: undefined }` and threw
PrismaClientValidationError, failing the whole delete transaction. Return early
instead.
* OUT-4093 | Remove the localStorage→localForage assignee migration
… Sentry

Two rejection paths per component: the optimistic mutate() was never awaited,
so its rejection escaped the surrounding try/catch, and debounceMutate() is
fire-and-forget. Both surface as unhandled rejections when fetcher() throws.

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

linear-code Bot commented Aug 26, 2026

Copy link
Copy Markdown

OUT-4109

@vercel

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

Request Review

@greptile-apps

greptile-apps Bot commented Aug 26, 2026

Copy link
Copy Markdown

Greptile Summary

This PR handles SWR mutation failures locally so expected fetch errors no longer surface as unhandled promise rejections.

  • Awaits optimistic mutations inside existing error-handling blocks for subtask, subtemplate, and comment creation.
  • Adds rejection handlers to debounced activity, subtask, and subtemplate revalidation.
  • Preserves the existing optimistic rollback and callback-consumer behavior.

Confidence Score: 5/5

The PR appears safe to merge, with no changed-code defect identified in the new rejection handling.

The awaited mutations now reach their existing rollback and cleanup handlers, while the debounced mutation catches only consume promises that no caller previously observed.

Important Files Changed

Filename Overview
src/app/configure-tasks-app/ui/Subtemplates.tsx Awaits subtemplate creation mutation and catches background revalidation failures without changing the established optimistic reconciliation flow.
src/app/detail/ui/ActivityWrapper.tsx Routes comment mutation failures through the existing catch and handles debounced activity revalidation rejection locally.
src/app/detail/ui/Subtasks.tsx Awaits subtask creation mutation and catches background revalidation failures while preserving existing rollback behavior.

Reviews (1): Last reviewed commit: "OUT-4109 | Handle SWR mutate rejections ..." | Re-trigger Greptile

@vercel

vercel Bot commented Aug 27, 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

@SandipBajracharya SandipBajracharya left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

lgtm

@priosshrsth
priosshrsth merged commit aa53df4 into main Aug 27, 2026
3 checks passed
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