-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
fix(webapp): collapse Prisma P1001 errors into a single Sentry issue #3632
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
d-cs
wants to merge
1
commit into
main
Choose a base branch
from
sentry-db-unreachable-fingerprint
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| --- | ||
| area: webapp | ||
| type: improvement | ||
| --- | ||
|
|
||
| Group Prisma P1001 ("Can't reach database server") errors into a single Sentry issue via a `beforeSend` fingerprint rule, so DB outages no longer fan out into hundreds of distinct issues that bury other alerts. Adds a small extensible rule table for future collapsing rules. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
🏁 Script executed:
Repository: triggerdotdev/trigger.dev
Length of output: 8678
🌐 Web query:
Prisma 6.14.0 error code P1001 KnownRequestError InitializationError code vs errorCode property💡 Result:
In Prisma, P1001 is a specific error code indicating that the Prisma Client cannot reach the database server [1][2]. This error is typically categorized as a PrismaClientInitializationError, which occurs when the query engine fails to start or establish a connection to the database [3][2]. Regarding the distinction between errorCode and code properties: 1. PrismaClientKnownRequestError uses the.code property to identify specific database-related errors (e.g., P2002 for unique constraint violations) [3][2]. 2. PrismaClientInitializationError is documented to use the.errorCode property to identify initialization-related errors, such as P1001 [4][2]. However, there is a known, long-standing issue where the errorCode property on PrismaClientInitializationError can intermittently return undefined [5][6][7]. This often happens when the error is thrown during an implicit connection attempt (e.g., the first query execution) rather than an explicit call to prisma.$connect [6]. Because of this inconsistency, developers are often advised to rely on the error message or to ensure explicit connection handling to improve reliability [6][7]. Regarding Prisma 6.14.0 specifically, users have reported regressions in this version, including breaking changes related to extending the PrismaClient class and issues with the engine connection state [8][9]. If you are encountering unexpected behavior with error handling in this version, it may be related to these broader architectural changes rather than a change in the error property definitions themselves [8].
Citations:
PrismaClientInitializationErroris missingerrorCodeproperty prisma/prisma#18813PrismaClientInitializationErroris missing expected error code prisma/prisma#10229P1001 is a PrismaClientInitializationError, not KnownRequestError—the error detection logic is partially incorrect.
The rule checks
err.code === "P1001" || err.errorCode === "P1001", but P1001 only appears onPrismaClientInitializationErrorvia the.errorCodeproperty. The.codeproperty is used only byPrismaClientKnownRequestErrorfor database errors (e.g., P2002). The check forerr.code === "P1001"will never match.Additionally, there is a known Prisma issue where
.errorCodeonInitializationErrorcan intermittently returnundefinedduring implicit connection attempts (e.g., on the first query execution). Relying solely on the.errorCodecheck may miss some P1001 errors. Consider either explicitly catchingPrismaClientInitializationErrorby type or handling the error message as a fallback.🤖 Prompt for AI Agents