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

Drizzle expression imports broken with latest sentry profiling version #15067

Closed
3 tasks done
livingforjesus opened this issue Jan 20, 2025 · 7 comments
Closed
3 tasks done
Labels
Package: node Issues related to the Sentry Node SDK

Comments

@livingforjesus
Copy link

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.50.0

Framework Version

No response

Link to Sentry event

No response

Reproduction Example/SDK Setup

https://github.com/livingforjesus/sentry-issue-repro

To reproduce just:

  • Replace process.env.DSN with a valid sentry dsn
  • Run pnpm i
  • Start via pnpm start.

Steps to Reproduce

We were on sentry v8.48.0 and tried upgrading to sentry v8.50.0. However upgrading sentry-profiling-node causes something weird to happen during our build process that makes certain drizzle expressions not to be exported. The expressions not exported are located in drizzle-orm/expressions/index.ts or something like that(in drizzle codebase). These throw an error whenever we try to access. Other functions from drizzle are exported and work normally

Note:

  • We use esm
  • We're using vite-node to execute the code
  • Everything works file until you upgrade sentry-profiling-node(sentry itself upgrades file) from v8.48.0 to v8.49.0

Expected Result

Everything works normally, I'm able to start api and operate as normal

Actual Result

TypeError: (0 , __vite_ssr_import_0__.isNotNull) is not a function
    at PgTable.<anonymous> (/Users/visiononyeaku/Desktop/Work/repro-sentry/src/schema.ts:14:47)
    at extractTablesRelationalConfig (file:///Users/visiononyeaku/Desktop/Work/repro-sentry/node_modules/.pnpm/[email protected]_@[email protected]_@[email protected][email protected][email protected]/node_modules/src/relations.ts:463:61)
    at construct (file:///Users/visiononyeaku/Desktop/Work/repro-sentry/node_modules/.pnpm/[email protected]_@[email protected]_@[email protected][email protected][email protected]/node_modules/src/postgres-js/driver.ts:48:24)
    at drizzle (file:///Users/visiononyeaku/Desktop/Work/repro-sentry/node_modules/.pnpm/[email protected]_@[email protected]_@[email protected][email protected][email protected]/node_modules/src/postgres-js/driver.ts:110:10)
    at /Users/visiononyeaku/Desktop/Work/repro-sentry/src/db.ts:4:16
    at ViteNodeRunner.runModule (file:///Users/visiononyeaku/Desktop/Work/repro-sentry/node_modules/.pnpm/[email protected]_@[email protected][email protected]/node_modules/vite-node/dist/client.mjs:399:5)
    at ViteNodeRunner.directRequest (file:///Users/visiononyeaku/Desktop/Work/repro-sentry/node_modules/.pnpm/[email protected]_@[email protected][email protected]/node_modules/vite-node/dist/client.mjs:381:5)
    at ViteNodeRunner.cachedRequest (file:///Users/visiononyeaku/Desktop/Work/repro-sentry/node_modules/.pnpm/[email protected]_@[email protected][email protected]/node_modules/vite-node/dist/client.mjs:206:14)
    at ViteNodeRunner.dependencyRequest (file:///Users/visiononyeaku/Desktop/Work/repro-sentry/node_modules/.pnpm/[email protected]_@[email protected][email protected]/node_modules/vite-node/dist/client.mjs:259:12)
    at /Users/visiononyeaku/Desktop/Work/repro-sentry/src/index.ts:4:1

Node.js v20.14.0
@getsantry getsantry bot moved this to Waiting for: Product Owner in GitHub Issues with 👀 3 Jan 20, 2025
@github-actions github-actions bot added the Package: node Issues related to the Sentry Node SDK label Jan 20, 2025
@andreiborza
Copy link
Member

Hi @livingforjesus, thanks for filing this. We are currently working on some improvements for sentry profiling that might be related.

Could you please provide a sample repo we can use to test with?

@livingforjesus
Copy link
Author

Yes @andreiborza . I provided this repo:
https://github.com/livingforjesus/sentry-issue-repro

@getsantry getsantry bot moved this to Waiting for: Product Owner in GitHub Issues with 👀 3 Jan 20, 2025
@andreiborza
Copy link
Member

Ahh, sorry I overlooked that. Taking a look.

@andreiborza
Copy link
Member

andreiborza commented Jan 20, 2025

Not sure what exactly is happening, but it might be that one of the recent otel bumps broke this. You can work around this by setting the following in your Sentry.init:

registerEsmLoaderHooks: {
   onlyIncludeInstrumentedModules: true,
}

This way import-in-the-middle only wraps over packages Sentry needs for instrumentation. We had a similar issue with hapi before, see the troubleshooting section here: https://docs.sentry.io/platforms/javascript/guides/hapi/install/esm/#troubleshooting-instrumentation

Let me know if this works for you.

@Lms24
Copy link
Member

Lms24 commented Jan 22, 2025

I think this is essentially a duplicate of #12912 (ignore the Astro part). Moreover, in v9, onlyIncludeInstrumentedModules will default to true (#14332).

IIRC the TLDR here is that the drizzle package has a very special way of specifying exports which import-in-the-middle can't really handle correctly. Hence, excluding it from being wrapped is probably the best option for now. Let us know of this works for you, then we'll close this issue.

@getsantry getsantry bot moved this to Waiting for: Community in GitHub Issues with 👀 3 Jan 22, 2025
@livingforjesus
Copy link
Author

Ok lemme try that

@getsantry getsantry bot moved this from Waiting for: Community to Waiting for: Product Owner in GitHub Issues with 👀 3 Jan 22, 2025
@livingforjesus
Copy link
Author

Yes works

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
Projects
Archived in project
Development

No branches or pull requests

3 participants