getsentry / sentry-javascript

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

Unable to run profiling-node on 32-bit operating system #12899

Open naheller opened 1 month ago

naheller commented 1 month ago

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

Framework Version

@sentry/node 8.17.0

Link to Sentry event

No response

SDK Setup/Reproduction Example

// Import with `import * as Sentry from "@sentry/node"` if you are using ESM
const Sentry = require("@sentry/node");
const { nodeProfilingIntegration } = require("@sentry/profiling-node");

Sentry.init({
  dsn: "https://<my-key>.ingest.us.sentry.io/4507555508453376",
  integrations: [nodeProfilingIntegration()],
  // Performance Monitoring
  tracesSampleRate: 1.0, //  Capture 100% of the transactions

  // Set sampling rate for profiling - this is relative to tracesSampleRate
  profilesSampleRate: 1.0,
});

Steps to Reproduce

  1. Install and setup Sentry for Fastify according to the guide
  2. Run project successfully on arm64 Mac
  3. Move project to 32-bit debian (raspberry pi OS)
  4. Run project
  5. Notice that the application crashes (See error in "Actual Result" section)

Expected Result

If precompiled binary is not found for the dynamically constructed source path, there should be fallback functionality that builds the required binary from source. In this case, for 32-bit linux.

Otherwise, if there is no automatic fallback behavior, there should be steps outlining a manual approach in the setup guide.

Actual Result

Notice the following error when running line require("@sentry/profiling-node") in Fastify app:

Error: Cannot find module '/home/node/app/node_modules/@sentry/profiling-node/lib/sentry_cpu_profiler-linux-arm-glibc-115.node'
Require stack:
- /home/node/app/node_modules/@sentry/profiling-node/lib/cjs/index.js
- /home/node/app/instrument.js
- /home/node/app/app.js
- /home/node/app/node_modules/fastify-cli/util.js
- /home/node/app/node_modules/fastify-cli/args.js
- /home/node/app/node_modules/fastify-cli/start.js
- /home/node/app/node_modules/fastify-cli/cli.js
     at Module._resolveFilename (node:internal/modules/cjs/loader:1145:15)
     at Module._load (node:internal/modules/cjs/loader:986:27)
     at Module.require (node:internal/modules/cjs/loader:1233:19)
     at require (node:internal/modules/helpers:179:18)
     at importCppBindingsModule (/home/node/app/node_modules/@sentry/profiling-node/lib/cjs/index.js:166:10)
     at Object.<anonymous> (/home/node/app/node_modules/@sentry/profiling-node/lib/cjs/index.js:169:36)
     at Module._compile (node:internal/modules/cjs/loader:1358:14)
     at Module._extensions..js (node:internal/modules/cjs/loader:1416:10)
     at Module.load (node:internal/modules/cjs/loader:1208:32)
     at Module._load (node:internal/modules/cjs/loader:1024:12) {
   code: 'MODULE_NOT_FOUND',
   requireStack: [
     '/home/node/app/node_modules/@sentry/profiling-node/lib/cjs/index.js',
     '/home/node/app/instrument.js',
     '/home/node/app/app.js',
     '/home/node/app/node_modules/fastify-cli/util.js',
     '/home/node/app/node_modules/fastify-cli/args.js',
     '/home/node/app/node_modules/fastify-cli/start.js',
     '/home/node/app/node_modules/fastify-cli/cli.js'
   ]
  | }
exited with code 1

Notice that @sentry/profiling-node is trying to use a precompiled binary that does not exist. The dynamic path builder is evaluating node_os.arch() to arm, since I'm on 32-bit Linux. I see that only 64-bit precompiled binaries are provided.

AbhiPrasad commented 1 month ago

We do have some docs about building the binary, but they are not detailed. @JonasBa we should probably add more docs about this. Going to backlog for now, but PRs are welcome.

Aside: One issue with using arch from node:os is that it records the architecture of where node was compiled - not where node is actually running. See https://www.npmjs.com/package/system-architecture (I have a long standing TODO to just PR a new API into node.js to fix this, let me see if I can just do it this weekend).