Skip to content

fix(node): Add compatibility layer for Prisma v5 #15169

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

Merged
merged 5 commits into from
Jan 28, 2025

Conversation

lforst
Copy link
Contributor

@lforst lforst commented Jan 27, 2025

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:engine spans 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.

@lforst lforst changed the title feat(node): Add compatibility layer for differnt Prisma majors fix(node): Add compatibility layer for Prisma v5 Jan 28, 2025
@lforst lforst marked this pull request as ready for review January 28, 2025 13:18
@lforst lforst requested review from mydea and AbhiPrasad January 28, 2025 15:14
Copy link
Member

@AbhiPrasad AbhiPrasad left a comment

Choose a reason for hiding this comment

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

Are we sure we want to do console.warn vs. using debug logging?

@lforst
Copy link
Contributor Author

lforst commented Jan 28, 2025

Are we sure we want to do console.warn vs. using debug logging?

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.

public enable(): void {
super.enable();

const prismaInstrumentationObject = (globalThis as Record<string, unknown>).PRISMA_INSTRUMENTATION;
Copy link
Member

Choose a reason for hiding this comment

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

m: Can we add a comment here explaining what and why we are doing here? For future reference :D

@lforst lforst merged commit 0963af0 into develop Jan 28, 2025
143 checks passed
@lforst lforst deleted the lforst-prisma-v6-compat-layer branch January 28, 2025 21:52
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.

3 participants