Skip to content
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

prismaInstrumentation.PrismaInstrumentation is not a constructor #11216

Closed
3 tasks done
gajus opened this issue Mar 20, 2024 · 8 comments · Fixed by #12185
Closed
3 tasks done

prismaInstrumentation.PrismaInstrumentation is not a constructor #11216

gajus opened this issue Mar 20, 2024 · 8 comments · Fixed by #12185
Labels
Package: node Issues related to the Sentry Node SDK Type: Bug
Milestone

Comments

@gajus
Copy link
Contributor

gajus commented Mar 20, 2024

Is there an existing issue for this?

How do you use Sentry?

Sentry Saas (sentry.io)

Which SDK are you using?

@sentry/node

SDK Version

8.0.0-alpha.4

Framework Version

No response

Link to Sentry event

No response

SDK Setup

N/A

Steps to Reproduce

Load script with node --loader=import-in-the-middle/hook.mjs ./dist/bin/server.js

Gives error:

030292a3 > This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). The promise rejected with the reason:
030292a3 > TypeError: prismaInstrumentation.PrismaInstrumentation is not a constructor
030292a3 >     at Object.setupOnce (file:///Users/x/Developer/contra/gaia/node_modules/.pnpm/@[email protected]/node_modules/@sentry/node/esm/index.js:2075:11)
030292a3 >     at setupIntegration (file:///Users/x/Developer/contra/gaia/node_modules/.pnpm/@[email protected]/node_modules/@sentry/core/esm/index.js:4927:17)
030292a3 >     at file:///Users/x/Developer/contra/gaia/node_modules/.pnpm/@[email protected]/node_modules/@sentry/core/esm/index.js:4897:7
030292a3 >     at Array.forEach (<anonymous>)
030292a3 >     at setupIntegrations (file:///Users/x/Developer/contra/gaia/node_modules/.pnpm/@[email protected]/node_modules/@sentry/core/esm/index.js:4894:16)
030292a3 >     at NodeClient._setupIntegrations (file:///Users/x/Developer/contra/gaia/node_modules/.pnpm/@[email protected]/node_modules/@sentry/core/esm/index.js:5396:26)
030292a3 >     at NodeClient.init (file:///Users/x/Developer/contra/gaia/node_modules/.pnpm/@[email protected]/node_modules/@sentry/core/esm/index.js:5249:12)
030292a3 >     at init (file:///Users/x/Developer/contra/gaia/node_modules/.pnpm/@[email protected]/node_modules/@sentry/node/esm/index.js:3104:12)
030292a3 >     at createSentry (file:///Users/x/Developer/contra/gaia/packages/sentry/dist/node.js:69:5)
030292a3 >     at file:///Users/x/Developer/contra/gaia/apps/contra-api/src/bin/server.ts:1:205

What worked was a dumb patch:

diff --git a/esm/index.js b/esm/index.js
index d9f5c81971e65b60e49a9ae7502c710bb4d2bd9d..bd28c7836c5b9e9075e611a117d80c1d66e7a82a 100644
--- a/esm/index.js
+++ b/esm/index.js
@@ -2072,7 +2072,7 @@ const _prismaIntegration = (() => {
       registerInstrumentations({
         instrumentations: [
           // does not have a hook to adjust spans & add origin
-          new prismaInstrumentation.PrismaInstrumentation({}),
+          // new prismaInstrumentation.PrismaInstrumentation({}),
         ],
       });
     },

All other modules load fine.

@getsantry getsantry bot moved this to Waiting for: Product Owner in GitHub Issues with 👀 2 Mar 20, 2024
@github-actions github-actions bot added the Package: node Issues related to the Sentry Node SDK label Mar 20, 2024
@AbhiPrasad
Copy link
Member

This is prisma/prisma#23410 - tracked by #11070.

Known issue that we will resolve before v8 comes out, maybe for now just have to disable prisma instrumentation in ESM builds (basically strip it out).

@AbhiPrasad AbhiPrasad added this to the 8.0.0 milestone Mar 20, 2024
@gajus
Copy link
Contributor Author

gajus commented Mar 20, 2024

Closing as duplicate. Thanks for the update.

@lforst
Copy link
Member

lforst commented May 14, 2024

@jnicklas Re your comment #11070 (comment). Are you manually using the prismaIntegration() with ESM?

@jnicklas
Copy link

@lforst yes, that's what I'm doing, maybe this is no longer necessary in the new version? This was not mentioned in the upgrade guide, so I'm not sure. I know there are some default integrations, but it's not quite clear which ones those are, and what I actually need to do.

@getsantry getsantry bot moved this to Waiting for: Product Owner in GitHub Issues with 👀 3 May 15, 2024
@mydea
Copy link
Member

mydea commented May 15, 2024

Generally, for now you do need to still add it manually in v8 (see: https://docs.sentry.io/platforms/javascript/guides/node/performance/database/#supported-platforms).

Can you show your Sentry.init(), as well as the relevant parts from your package.json?

@lilouartz
Copy link

Could not get it to work with Remix ESM.

@getsantry getsantry bot moved this to Waiting for: Product Owner in GitHub Issues with 👀 3 May 16, 2024
@mydea
Copy link
Member

mydea commented May 17, 2024

We'll need to investigate ESM support for this some more. I think there are some fundamental incpompatibilies there, but not 100% sure, cc @timfish and @AbhiPrasad you've looked into this more in the past!

@danthareja
Copy link

I had the same issue in an ESM build using --import ./instrument.js.

Versions:

  • Node v20.13.1
  • @sentry/node 8.3.0
  • @prisma/instrumentation 5.14.0

I fixed this with the following patch (applied with with patch-package)

# patches/@sentry+node+8.3.0.patch
diff --git a/node_modules/@sentry/node/esm/integrations/tracing/prisma.js b/node_modules/@sentry/node/esm/integrations/tracing/prisma.js
index abe7880..0b2a7a6 100644
--- a/node_modules/@sentry/node/esm/integrations/tracing/prisma.js
+++ b/node_modules/@sentry/node/esm/integrations/tracing/prisma.js
@@ -1,5 +1,5 @@
 import { _optionalChain } from '@sentry/utils';
-import * as prismaInstrumentation from '@prisma/instrumentation';
+import prismaInstrumentation from '@prisma/instrumentation';
 import { defineIntegration, spanToJSON, SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN } from '@sentry/core';
 import { addOpenTelemetryInstrumentation } from '@sentry/opentelemetry';

@getsantry getsantry bot moved this to Waiting for: Product Owner in GitHub Issues with 👀 3 May 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Package: node Issues related to the Sentry Node SDK Type: Bug
Projects
Archived in project
Archived in project
8 participants