getsentry / sentry-javascript

Official Sentry SDKs for JavaScript
https://sentry.io
MIT License
7.76k stars 1.52k forks source link

Nestjs Sentry Cannot Find Binary #12756

Open alperen-bircak opened 3 days ago

alperen-bircak commented 3 days ago

Is there an existing issue for this?

How do you use Sentry?

Sentry Saas (sentry.io)

Which SDK are you using?

@sentry/nestjs

SDK Version

8.13.0

Framework Version

10.3.9

Link to Sentry event

No response

SDK Setup/Reproduction Example

import * as Sentry from '@sentry/nestjs';
import { nodeProfilingIntegration } from '@sentry/profiling-node';

if (process.env.NODE_ENV === 'development') {
  // eslint-disable-next-line no-console
  console.log('Sentry is disabled in development mode');
}
// Ensure to call this before requiring any other modules!
Sentry.init({
  dsn: '...', // Omitted
  integrations: [
    // Add our Profiling integration
    nodeProfilingIntegration(),
  ],

  // Add Tracing by setting tracesSampleRate
  // We recommend adjusting this value in production
  tracesSampleRate: 1.0,

  // Set sampling rate for profiling
  // This is relative to tracesSampleRate
  profilesSampleRate: 1.0,

  enabled: process.env.NODE_ENV !== 'development',
  environment: process.env.SENTRY_ENVIRONMENT,
});

Steps to Reproduce

  1. Add sentry to nestjs project
  2. Configure according to docs
  3. Run the project

Expected Result

Project to run

Actual Result

Error: Cannot find module '<path omitted>\node_modules\.pnpm\@sentry+profiling-node@8.13.0\node_modules\@sentry\profiling-node\lib\sentry_cpu_profiler-win32-x64-120.node'
Require stack:
- <path omitted>\node_modules\.pnpm\@sentry+profiling-node@8.13.0\node_modules\@sentry\profiling-node\lib\cjs\index.js
- <path omitted>\dist\src\insturment.js
- <path omitted>\dist\src\main.js
    at Function.Module._resolveFilename (node:internal/modules/cjs/loader:1144:15)
    at Function.Module._load (node:internal/modules/cjs/loader:985:27)
    at Module.require (node:internal/modules/cjs/loader:1235:19)
    at require (node:internal/modules/helpers:176:18)
    at importCppBindingsModule (<path omitted>\node_modules\.pnpm\@sentry+profiling-node@8.13.0\node_modules\@sentry\profiling-node\src\cpu_profiler.ts:156:93)
    at Object.<anonymous> (<path omitted>\node_modules\.pnpm\@sentry+profiling-node@8.13.0\node_modules\@sentry\profiling-node\src\cpu_profiler.ts:159:93)
    at Module._compile (node:internal/modules/cjs/loader:1376:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1435:10)
    at Module.load (node:internal/modules/cjs/loader:1207:32)
    at Function.Module._load (node:internal/modules/cjs/loader:1023:12)\
chargome commented 3 days ago

Hi @alperen-bircak thanks for reaching out. Would you mind sharing a reproducible repo? This would help to track down the error more quickly.

lforst commented 3 days ago

I think this might be us not supporting the 120 node abi. @alperen-bircak which node version are you using?

cc @JonasBa

alperen-bircak commented 3 days ago

Hello, my node version is "v21.2.0". I cant share the repo since it's internal, but I will try to create a reproducible repo if the issue can't be found.

AbhiPrasad commented 3 days ago

@alperen-bircak we only pre-build binaries for LTS Node versions: https://github.com/getsentry/sentry-javascript/blob/develop/packages/profiling-node/README.md#prebuilt-binaries (v16, v18, v20, v22).

If you add debug: true to your Sentry.init call, you will see a warning about this.

I recommend upgrading to Node 22