fix(webapp): collapse Prisma P1001 errors into a single Sentry issue#3632
Conversation
DB outages currently produce hundreds of distinct Sentry issues — one per call site — which buries other alerts. Add a beforeSend rule that detects err.code === "P1001" (KnownRequestError when a connection drops mid-query) or err.errorCode === "P1001" (InitializationError when the client fails to connect at startup) and assigns a stable fingerprint plus a db_unreachable tag so all P1001 events collapse into one issue regardless of stack trace. The rule list is extensible — additional fan-out errors can be added with one entry. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
WalkthroughThis change introduces Sentry fingerprint-based grouping for Prisma P1001 database connectivity errors. A new Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Summary
beforeSendrule inapps/webapp/sentry.server.tsthat collapses PrismaP1001("Can't reach database server") errors into a single Sentry issue regardless of which call site threw, by settingevent.fingerprint = ["prisma-p1001-db-unreachable"]and taggingdb_unreachable:true.err.code === "P1001"(Prisma'sKnownRequestErrorwhen a connection drops mid-query) anderr.errorCode === "P1001"(InitializationErrorwhen the client fails to connect at startup).FINGERPRINT_RULEStable so further fan-out errors can be added with one entry.Verification
End-to-end verified locally with
debug: trueon the SDK:P1001thrown from a loader (DB stopped mid-request) is captured by Sentry's Remix auto-instrumentationbeforeSendfires withoriginalException.code === "P1001", rule matchesevent.fingerprint = ["prisma-p1001-db-unreachable"]andtags.db_unreachable = "true"appliedTest plan
prisma-p1001-db-unreachableissue rather than fanning outdb_unreachable:truetag is filterable in SentrybeforeSenduntouched)🤖 Generated with Claude Code