fix(node): Add compatibility layer for Prisma v5#15169
Merged
Conversation
added 2 commits
January 27, 2025 13:39
AbhiPrasad
approved these changes
Jan 28, 2025
Contributor
AbhiPrasad
left a comment
There was a problem hiding this comment.
Are we sure we want to do console.warn vs. using debug logging?
Contributor
Author
pretty sure yes. The log message will only show up when people actually use prisma v5 and v9 and it's a pretty big deal. |
mydea
reviewed
Jan 28, 2025
| public enable(): void { | ||
| super.enable(); | ||
|
|
||
| const prismaInstrumentationObject = (globalThis as Record<string, unknown>).PRISMA_INSTRUMENTATION; |
Member
There was a problem hiding this comment.
m: Can we add a comment here explaining what and why we are doing here? For future reference :D
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
This PR adds a shim to the internal Prisma tracing helper to prevent Prisma v5 from crashing when accessing a property on the tracing helper registered by the Prisma v6 integration that doesn't exist.
For more context see the upstream PR: prisma/prisma#26167
Note: I have tried to actually implement full compatibility, also emitting
prisma:enginespans that contain the query. The problem is that these spans are passed by the prisma engine/binary to the TS layer individually, but in the format of a tree. The root node of the tree points to the current span when the query was made, however, since the nodes are passed individually, we cannot (at least with non-deprecated OTEL APIs) reconstruct that tree with materialzed (non-serialized) spans, because OTEL doesn't give you a way to set the IDs of spans.