Skip to content

feat(node): Support Prisma 8 in prismaIntegration - #24682

Open
chargome wants to merge 1 commit into
feat/prisma-8-testsfrom
feat/prisma-8-instrumentation
Open

chargome wants to merge 1 commit into
feat/prisma-8-testsfrom
feat/prisma-8-instrumentation

Conversation

@chargome

@chargome chargome commented Sep 24, 2026 •

Copy link
Copy Markdown
Member

Wraps Prisma 8's ORM terminals via orchestrion: each ORM call gets a prisma:client:operation span (sentry.op: db, db.operation.name, db.collection.name, plus v7's method/model/name) with the pg query spans nested underneath. No user code needed.

  • Patch point is CollectionImpl in the transitive @prisma/orm-family-sql, pinned >=8.0.0-rc.8 <9; verified on rc.8.
  • Lazy terminals (all, createAll, updateAll, deleteAll) return a single-use thenable that orchestrion's promise wrapper would consume, so they're wrapped Sync and the subscriber hooks consumption instead.
  • Nested terminal calls reuse the outer span. Operation spans require a parent.
  • CJS apps on Node 20 keep pg-only spans, since require(esm) bypasses the module hooks there. From Node 22 on they're covered; with the async hooks (before Node 24.13 / 25.1) a call in the same tick as the require runs before the SDK subscribes. ESM apps are fully covered.
  • Bumps the @sentry/node size limits for the added instrumentation config.

Fixes #24237

@chargome
chargome added this pull request to stack #24684 September 24, 2026 09:07
@chargome chargome self-assigned this Sep 24, 2026
@chargome

Copy link
Copy Markdown
Member Author

bugbot run

@cursor cursor Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Stale Bugbot comment from a previous run.

Comment thread packages/server-utils/src/integrations/prisma/orchestrion.ts
end(error);
return Promise.reject(error);
}
return settle(runUnderSpan(span, () => iterator.throw!(error)));

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Uncommented non-null assertions

Low Severity

iterator.return! and iterator.throw! are non-null assertions with no comment on why a narrower type is not possible. Flagged because the review rules require that explanation on new ! assertions in SDK source.

Additional Locations (1)
Fix in Cursor Fix in Web

Triggered by project rule: PR Review Guidelines for Cursor Bot

Reviewed by Cursor Bugbot for commit 4e7097b. Configure here.

@github-actions

github-actions Bot commented Sep 24, 2026 •

Copy link
Copy Markdown
Contributor

size-limit report 📦

Path Size % Change Change
@sentry/browser 29.24 kB - -
@sentry/browser - with treeshaking flags 27.5 kB - -
@sentry/browser - with treeshaking flags tracing without tracing 27.4 kB - -
@sentry/browser (incl. Tracing) 51.15 kB - -
@sentry/browser (incl. Tracing + Span Streaming) 51.17 kB - -
@sentry/browser (incl. Tracing, Profiling) 54.18 kB - -
@sentry/browser (incl. Tracing, Replay) 90.76 kB - -
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags 79.86 kB - -
@sentry/browser (incl. Tracing, Replay with Canvas) 95.46 kB - -
@sentry/browser (incl. Tracing, Replay, Feedback) 108.41 kB - -
@sentry/browser (incl. Feedback) 46.76 kB - -
@sentry/browser (incl. sendFeedback) 34.3 kB - -
@sentry/browser (incl. FeedbackAsync) 39.41 kB - -
@sentry/browser (incl. Metrics) 30.25 kB - -
@sentry/browser (incl. Logs) 30.51 kB - -
@sentry/browser (incl. Metrics & Logs) 31.18 kB - -
@sentry/react 31 kB - -
@sentry/react (incl. Tracing) 53.45 kB - -
@sentry/vue 36.74 kB - -
@sentry/vue (incl. Tracing) 53.7 kB - -
@sentry/svelte 29.26 kB - -
CDN Bundle 30.93 kB - -
CDN Bundle (incl. Tracing) 51.69 kB - -
CDN Bundle (incl. Logs, Metrics) 33.2 kB - -
CDN Bundle (incl. Tracing, Logs, Metrics) 53.66 kB - -
CDN Bundle (incl. Replay, Logs, Metrics) 73.92 kB - -
CDN Bundle (incl. Tracing, Replay) 89.28 kB - -
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) 91.25 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback) 95.45 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) 97.42 kB - -
CDN Bundle - uncompressed 91.4 kB - -
CDN Bundle (incl. Tracing) - uncompressed 153.77 kB - -
CDN Bundle (incl. Logs, Metrics) - uncompressed 97.97 kB - -
CDN Bundle (incl. Tracing, Logs, Metrics) - uncompressed 159.73 kB - -
CDN Bundle (incl. Replay, Logs, Metrics) - uncompressed 227.54 kB - -
CDN Bundle (incl. Tracing, Replay) - uncompressed 273.5 kB - -
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) - uncompressed 279.44 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed 287.2 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) - uncompressed 293.13 kB - -
@sentry/nextjs (client) 55.77 kB - -
@sentry/sveltekit (client) 51.59 kB - -
@sentry/core/server 39.95 kB - -
@sentry/core/browser 13.63 kB - -
@sentry/node 136.47 kB +1.94% +2.6 kB 🔺
@sentry/node/import (ESM hook with diagnostics-channel injection) 82.54 kB +0.17% +138 B 🔺
@sentry/node - without tracing 90.56 kB +0.16% +143 B 🔺
@sentry/node - without channel injection 114.93 kB +2.25% +2.53 kB 🔺
@sentry/aws-serverless 98.83 kB +0.15% +141 B 🔺
@sentry/cloudflare (withSentry) - minified 206.49 kB - -
@sentry/cloudflare (withSentry) 513.73 kB - -

View base workflow run

@chargome
chargome force-pushed the feat/prisma-8-instrumentation branch from 4e7097b to 685f3c5 Compare September 24, 2026 09:30
@chargome

Copy link
Copy Markdown
Member Author

bugbot run

@cursor cursor Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Stale Bugbot comment from a previous run.

expect(operationSpans).toEqual([]);
querySpans.forEach(span => expect(span.parent_span_id).toBe(segment?.span_id));
return;
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Test branches on instrumentation mode

Low Severity

The new Prisma v8 test branches on expectsOperationSpans and returns early for the CJS-on-older-Node path. That hides two different user-visible outcomes in one case: operation spans nested over pg queries versus pg-only spans parented to the transaction. This was flagged because the review rules call out conditionals in a single test.

Fix in Cursor Fix in Web

Triggered by project rule: PR Review Guidelines for Cursor Bot

Reviewed by Cursor Bugbot for commit 685f3c5. Configure here.

@chargome
chargome force-pushed the feat/prisma-8-instrumentation branch from 685f3c5 to 3e27580 Compare September 24, 2026 09:39
@chargome

Copy link
Copy Markdown
Member Author

bugbot run

@cursor cursor Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Stale Bugbot comment from a previous run.

Prisma 8 has no tracing surface, so wrap its ORM terminals via
orchestrion instead. Each ORM call gets a `prisma:client:operation` span
(`db.operation.name`, `db.collection.name`, plus v7's `method`, `model`
and `name`) with the `pg` query spans nested underneath. No user code
is needed.

The patch point is `CollectionImpl` in the transitive
`@prisma/orm-family-sql` package, pinned to `>=8.0.0-rc.8 <9`. Lazy
terminals (`all`, `createAll`, `updateAll`, `deleteAll`) return a
single-use thenable that orchestrion's promise wrapper would consume,
so they are wrapped `Sync` and the subscriber hooks `toArray` and the
async iterator instead. Terminals calling terminals reuse the outer
span. Operation spans require a parent span.

CommonJS apps load the ESM-only runtime through `require(esm)`, which
only the synchronous module hooks (Node 24.13 / 25.1) transform; older
Node keeps `pg`-only spans in CJS. ESM apps are fully covered.

Fixes #24237
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@chargome
chargome force-pushed the feat/prisma-8-instrumentation branch from 3e27580 to 268cb2f Compare September 24, 2026 10:13
@chargome

Copy link
Copy Markdown
Member Author

bugbot run

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit 268cb2f. Configure here.

@chargome
chargome marked this pull request as ready for review September 24, 2026 12:03
@chargome
chargome requested review from a team as code owners September 24, 2026 12:03
@chargome
chargome requested review from JPeer264, andreiborza and isaacs and removed request for a team September 24, 2026 12:03

This branch has not been deployed

No deployments
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.

Prisma 8 support for prismaIntegration

1 participant