Skip to content
This repository has been archived by the owner on Sep 17, 2024. It is now read-only.

1.0.7 ./sentry_cpu_profiler-darwin-arm64-115.node not found #171

Closed
3 tasks done
andylacko opened this issue Jun 30, 2023 · 46 comments
Closed
3 tasks done

1.0.7 ./sentry_cpu_profiler-darwin-arm64-115.node not found #171

andylacko opened this issue Jun 30, 2023 · 46 comments

Comments

@andylacko
Copy link

Is there an existing issue for this?

How do you use Sentry?

Sentry Saas (sentry.io)

SDK Version

1.0.7

Link to Sentry event

No response

What environment is your node script running in?

20.3.1
pnpm

How is your code deployed and bundled?

webpack

Steps to Reproduce

try to run project

Expected Result

work

Actual Result

Error: Cannot find module './sentry_cpu_profiler-darwin-arm64-115.node'
Require stack:

  • /Users/andy/Developer/intellcre/node_modules/.pnpm/@sentry[email protected]/node_modules/@sentry/profiling-node/lib/index.js
  • /Users/andy/Developer/intellcre/services/api/dist/services/api/src/main.js
    at Function.Module._resolveFilename (node:internal/modules/cjs/loader:1072:15)
    at Function.Module._load (node:internal/modules/cjs/loader:925:27)
    at Module.require (node:internal/modules/cjs/loader:1139:19)
    at require (node:internal/modules/helpers:121:18)
    at /Users/andy/Developer/intellcre/node_modules/.pnpm/@sentry[email protected]/node_modules/@sentry/profiling-node/lib/index.js:16691:57
    at importCppBindingsModule (/Users/andy/Developer/intellcre/node_modules/.pnpm/@sentry[email protected]/node_modules/@sentry/profiling-node/lib/index.js:16691:14)
    at /Users/andy/Developer/intellcre/node_modules/.pnpm/@sentry[email protected]/node_modules/@sentry/profiling-node/lib/index.js:16717:32
    ^C/Users/andy/Developer/intellcre/services/api:
     ERR_PNPM_RECURSIVE_RUN_FIRST_FAIL  [email protected] start:dev: pnpm run assets:copy && nest start --watch
    Command failed with signal "SIGTERM"
     ELIFECYCLE  Command failed.
@stephenhmarsh
Copy link

Yeah I get almost the same error in my Next.js project running @sentry/profiling-node 1.0.7 (latest published)

Error: Cannot find module './sentry_cpu_profiler-darwin-arm64-108.node'
Require stack:
- /Users/stephen/dev/met-js/web/node_modules/@sentry/profiling-node/lib/index.js
- /Users/stephen/dev/met-js/web/.next/server/pages/_document.js
- /Users/stephen/dev/met-js/web/node_modules/next/dist/server/require.js
- /Users/stephen/dev/met-js/web/node_modules/next/dist/server/load-components.js
- /Users/stephen/dev/met-js/web/node_modules/next/dist/build/utils.js
- /Users/stephen/dev/met-js/web/node_modules/next/dist/server/dev/static-paths-worker.js
- /Users/stephen/dev/met-js/web/node_modules/next/dist/compiled/jest-worker/processChild.js
    at Module._resolveFilename (node:internal/modules/cjs/loader:1047:15)
    at /Users/stephen/dev/met-js/web/node_modules/next/dist/server/require-hook.js:189:36
    at Module._load (node:internal/modules/cjs/loader:893:27)
    at Module.require (node:internal/modules/cjs/loader:1113:19)
    at require (node:internal/modules/cjs/helpers:103:18)
    at /Users/stephen/dev/met-js/web/node_modules/@sentry/profiling-node/lib/index.js:16691:57
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async importCppBindingsModule (/Users/stephen/dev/met-js/web/node_modules/@sentry/profiling-node/lib/index.js:16691:14)
    at async /Users/stephen/dev/met-js/web/node_modules/@sentry/profiling-node/lib/index.js:16717:32

It looks like #173 would fix this. Running those commands separately and manually from the terminal resolved this.

@JonasBa
Copy link
Member

JonasBa commented Jul 6, 2023

We've released 1.0.8 and some folks internally at Sentry who had issues have said that they now seem to be resolved. Do you mind upgrading and letting me know if this still happens?

@Klaitos
Copy link

Klaitos commented Jul 10, 2023

Error still persists Cannot find module './sentry_cpu_profiler-darwin-arm64-115.node with node v18.16.0 and @sentry/profiling-node 1.0.8

@Klaitos
Copy link

Klaitos commented Jul 10, 2023

For those having the issue, I've found in the code the following workaround :
Set a env var before running your code :
SENTRY_PROFILER_BINARY_PATH=./sentry_cpu_profiler-darwin-arm64-108.node

@whaagmans
Copy link
Contributor

SENTRY_PROFILER_BINARY_PATH=./sentry_cpu_profiler-darwin-arm64-108.node

I don't have this token set. Where is yours located? It could be due to the token being set it overrides the default space it looks for the file.

@Klaitos
Copy link

Klaitos commented Jul 10, 2023

The issue is here https://github.com/getsentry/profiling-node/blob/main/src/cpu_profiler.ts#L2, the versions variable returned by the import is 20.4, while my code is running on node 18.16.

@whaagmans
Copy link
Contributor

whaagmans commented Jul 10, 2023

The issue is here https://github.com/getsentry/profiling-node/blob/main/src/cpu_profiler.ts#L2, the versions variable returned by the import is 20.04, while my code is running on node 18.04. I guess this var is read at the build time, when you build and upload the package it is saved inside.

Maybe I am missing something but based on the Node docs the process.versions has been in there since 0.2 with the last update in 9.0. https://nodejs.org/docs/latest-v18.x/api/process.html#processversions So maybe the problem is in another part. But still weird that adding the ENV solves it.

You don't have a --ignore-scripts anywhere in you npm specified. You can check by with npm config get ignore-scripts

@Klaitos
Copy link

Klaitos commented Jul 10, 2023

No I don't npm ignore scripts

@Klaitos
Copy link

Klaitos commented Jul 10, 2023

Oh I found this is related to yarn, because when I start my server with npm (and nodemon) this works !

@whaagmans
Copy link
Contributor

whaagmans commented Jul 10, 2023

Interesting since I use yarn 😅. But then again I am also on the latest node version so maybe there lies the crux. But happy that it works at least.

@Klaitos
Copy link

Klaitos commented Jul 10, 2023

For my case, it appears that the issue was a conflict on where and how was installed node and yarn on my laptop.

I had a yarn version installed with brew and a node version with brew also but not used, my default node binary was the one installed with nvm. (type which node)

When I used yarn dlx to use nodemon and ts-node to start my server which is using your library, the node 20.4 version (the brew one) was used by yarn for any reason.

To fix this, I executed brew remove yarn and corepack enable, yarn dlx is now using my default node binary.

Hope that helps someone, not sure if it the same reason than @andylacko.

@JonasBa
Copy link
Member

JonasBa commented Jul 17, 2023

Anyone on the latest version of the package still experiencing this problem?

@nicksrandall
Copy link

Anyone on the latest version of the package still experiencing this problem?

Yes, I'm still seeing this issue with PNPM.

@whaagmans
Copy link
Contributor

Anyone on the latest version of the package still experiencing this problem?

Yes, I'm still seeing this issue with PNPM.

Probably you've already tried this but as a novelty, have you've already tried:

  1. Remove the node_modules directory and the lock file (pnpm-lock.yaml).
  2. pnpm store prune
  3. Run pnpm install again.
  4. Check whether the package in question is at the correct version by using pnpm list [package-name].

@JonasBa
Copy link
Member

JonasBa commented Jul 19, 2023

@nicksrandall can you please run a clean install as @whaagmans suggested? I just attempted to install the package via pnpm, build and run and I could not reproduce your error.

@yash-coded
Copy link

This is still unusable in M1 macs. Did anyone find a workaround for this?

@JonasBa
Copy link
Member

JonasBa commented Jul 28, 2023

@yash-coded are you using pnpm as well?

@yash-coded
Copy link

Hey @JonasBa, I'm using node v18.16.1 (npm v9.5.1)

@JonasBa
Copy link
Member

JonasBa commented Jul 28, 2023

@yash-coded are you by any chance ignoring install scripts? What does npm config get ignore-scripts output? Can you bump the package to version 1.1.2?

@nicksrandall
Copy link

@JonasBa I did a clean install and realized that I think the issue is with my bundler and maybe not pnpm? I'm using remix (which is using esbuild) and the server fails to start when I'm using this package because node can't find the .node file

@yash-coded
Copy link

ignore-scripts is set to false and we're already on 1.1.2
Screenshot 2023-07-28 at 7 51 29 AM

@yash-coded
Copy link

Screenshot 2023-07-28 at 7 46 23 AM
Getting this error when I run my server but i didn't get any errors during installation.

@JonasBa
Copy link
Member

JonasBa commented Jul 28, 2023

@yash-coded, you are running the script with node 16 - it looks for binary compatible with 93 identifier which corresponds to node 16 and not node 18 as you mentioned.

CleanShot 2023-07-28 at 10 08 40@2x

Can you make sure to run the script with node 18?

@yash-coded
Copy link

Sorry about that, i switched to node 16 just to try another version when I took the screenshot but I was getting the same error with node 18: node_modules/@sentry/profiling-node/lib/sentry_cpu_profiler-darwin-arm64-108.node, 0x0001)

@JonasBa
Copy link
Member

JonasBa commented Jul 28, 2023

@yash-coded I dont think your install script ran for some reason (or your node version was different at install time). Can you cd into node_modules/@sentry/profiling-node and manually run node scripts/check-build.mjs and tell me what it outputs? This should detect the runtime error and trigger a rebuild from source.

@yash-coded
Copy link

yash-coded commented Jul 28, 2023

This was with node 16 but I got the same result with node v18

@sentry/profiling-node: Precompiled binary found, attempting to load /path/to/repo/node_modules/@sentry/profiling-node/lib/sentry_cpu_profiler-darwin-arm64-93.node
@sentry/profiling-node: Precompiled binary found but failed loading
@sentry/profiling-node: Compiling from source...

@JonasBa
Copy link
Member

JonasBa commented Jul 28, 2023

Hmm, I think compiling from source might fail here and we may be swallowing error. If a binary is successfully compiled from source on your local machine then it should work (or at least the error would have been different)

do you mind running npm run build:configure,npm run build:bindings and node scripts/copy-target.mjs in this order from the profiling dir and seeing if any of these fail?

@yash-coded
Copy link

npm run build:configure didn't fail but got following responses from other two commands

❯ npm run build:bindings

> @sentry/[email protected] build:bindings
> node-gyp build && node scripts/copy-target.mjs

gyp info it worked if it ends with ok
gyp info using [email protected]
gyp info using [email protected] | darwin | arm64
gyp info spawn make
gyp info spawn args [ 'BUILDTYPE=Release', '-C', 'build' ]
make ✖ ERR  Missing Makefile / Bakefile 
make ℹ info Run "make init" to generate a Makefile.
gyp info ok 
Source file does not exist: /path/to/repo/node_modules/@sentry/profiling-node/build/Release/sentry_cpu_profiler.node
❯ node scripts/copy-target.mjs
Source file does not exist: /path/to/repo/node_modules/@sentry/profiling-node/build/Release/sentry_cpu_profiler.node

@JonasBa
Copy link
Member

JonasBa commented Jul 28, 2023

Quick search for that error finds nodejs/node-report#102 (comment)

Do you have a make package installed that is being confused by make from the build toolchain?

@mrmckeb
Copy link

mrmckeb commented Aug 4, 2023

I'm hitting this issue too.

Error: Cannot find module '[project-path]/node_modules/.pnpm/@[email protected]/node_modules/@sentry/profiling-node/lib/sentry_cpu_profiler-darwin-arm64-110.node'

I see the following sentry_cpu_profiler-darwin-arm64-* modules installed.

image

@JonasBa
Copy link
Member

JonasBa commented Aug 4, 2023

@mrmckeb mind running the steps that I described manually in and tell me if you see errors? #171 (comment)

@JonasBa
Copy link
Member

JonasBa commented Aug 28, 2023

Closing due to inactivity. @mrmckeb please make sure you don't have a "make" package installed that is confusing the build toolchain. Feel free to reopen the issue if you still have a problem - I would just ask you to re-run the commands I described in #171 and paste the output so we can efficiently debug

@JonasBa JonasBa closed this as completed Aug 28, 2023
@miteshkotak
Copy link

miteshkotak commented Aug 29, 2023

I faced the similar issue issue with M1 Macs , Node 20.5.1, npm : 8.5.5

running npm i @sentry/profiling-node ( latest package removed the error for me)

@nicksrandall
Copy link

This is also not working for me. Basic Remix app.

@JonasBa
Copy link
Member

JonasBa commented Aug 29, 2023

@nicksrandall mind opening a new issue with an example stacktrace? This issue has been polluted by a mix of a few different errors (and causes) and I would like to not add to it.

@theobouwman
Copy link

I am seeing the same error on Google Cloud Run:

Error: Cannot find module '/usr/src/app/node_modules/@sentry/profiling-node/lib/sentry_cpu_profiler-linux-x64-glibc-120.node'

I am using this template https://github.com/GoogleCloudPlatform/cloud-run-microservice-template-nodejs

@jamespsterling
Copy link

I am seeing the same error on Google Cloud Run:

Error: Cannot find module '/usr/src/app/node_modules/@sentry/profiling-node/lib/sentry_cpu_profiler-linux-x64-glibc-120.node'

I am using this template https://github.com/GoogleCloudPlatform/cloud-run-microservice-template-nodejs

I am seeing this on MacOS M2 Max as well.

@JonasBa
Copy link
Member

JonasBa commented Mar 25, 2024

@jamespsterling @theobouwman It seems like this is attempting to load the binaries for Node version 21. We do not officially support non LTS node versions and we do not provide precompiled binaries for these environments - v21 is not LTS. You will have to compile the binaries yourself and install the required tooling (which depends on the images you are using, but tipically involves python, git and a couple other build tools). The alternative is to downgrade to v20 or wait for when v22 reaches LTS and we provide precompiled binaries.

@dancrumb
Copy link

In case this helps others: I was seeing this issue on a fresh Ubuntu box.

I'd install node via nvm.

Once I installed node-gyp via apt, everything worked correctly for me. Installing that brought in a lot of dependencies, so I couldn't say for sure whether it was node-gyp or a dependency that solved the issue.

@pppdns
Copy link

pppdns commented Apr 24, 2024

@jamespsterling @theobouwman It seems like this is attempting to load the binaries for Node version 21. We do not officially support non LTS node versions and we do not provide precompiled binaries for these environments - v21 is not LTS. You will have to compile the binaries yourself and install the required tooling (which depends on the images you are using, but tipically involves python, git and a couple other build tools). The alternative is to downgrade to v20 or wait for when v22 reaches LTS and we provide precompiled binaries.

🎉🎉🎉 Switching to Node v20 from v21 fixed the issue for me! 🎉🎉🎉

package.json:

  "engines": {
    "node": "20"
  },

I'm using ubuntu-22 on DigitalOcean (default DO image) and npm.

@pppdns
Copy link

pppdns commented Jul 7, 2024

I got Node 22 to work (even though it's not yet LTS...) by updating these Sentry packages to their latest versions in package.json.

      "@sentry/cli": "^2.32.0",
      "@sentry/node": "^8.15.0",
      "@sentry/profiling-node": "^8.15.0",
...
  "engines": {
    "node": "22"
  },

I did this because Node 20 suddenly started throwing errors during build and deployment in the Sentry step.

We do not officially support non LTS node versions and we do not provide precompiled binaries for these environments

It looks like these Sentry binary versions are highly unreliable. It would be nice to have a more robust and reliable automatic build process at Sentry to build these binaries for all Node versions (not just LTS).

My LTS Node 20 suddenly started throwing errors during build, but the non-LTS Node 22 works, which is not supposed to work based on the above comment that I quoted

@JonasBa
Copy link
Member

JonasBa commented Jul 7, 2024

@pppdns It has been a while since that comment and we actually build binaries for v22 since a few months now, so the binaries working for v22 is expected.

I did this because Node 20 suddenly started throwing errors during build and deployment in the Sentry step.

Would you mind sharing what sort of errors you were seeing? Did you upgrade or change anything in your environment? Our code here hadnt changed, so I suspect there might be something external that caused this. Please send us the error so we can investigate

Regarding the binaries being unreliable, I would disagree that it's the actual binaries that are unreliable. That said, there is a lot of confusion and required knowledge around how nodejs and bundling works with native binaries which can unfortunately lead to errors in the setup. We'll try see if we can improve that.

@pppdns
Copy link

pppdns commented Jul 14, 2024

I'll see if I can get the error logs, if yes, I will post them.

Regarding the confusion around how these binaries are supposed to work, some extra documentation would be nice. I don't think it's available for the public currently

@JefferyHus
Copy link

Not sure why this started happening just today, the project was running fine and is in production but just trying to run it today in my local it gave me the same error:

npm error   code: 'MODULE_NOT_FOUND',
npm error   requireStack: [
npm error     '/Users/path/to/node_modules/@sentry/profiling-node/scripts/check-build.js'
npm error   ]
npm error }
npm error
npm error Node.js v20.15.1

@codeyourwayup
Copy link

The issue is here https://github.com/getsentry/profiling-node/blob/main/src/cpu_profiler.ts#L2, the versions variable returned by the import is 20.4, while my code is running on node 18.16.

There is an issue because the code checks your current Node.js version and retrieves the abi for version "21.0.0" (which is 120). Therefore, if I use Node.js version 18.18.0, it will use the correct profiling version. It worked!

@JonasBa
Copy link
Member

JonasBa commented Sep 9, 2024

The issue is here https://github.com/getsentry/profiling-node/blob/main/src/cpu_profiler.ts#L2, the versions variable returned by the import is 20.4, while my code is running on node 18.16.

There is an issue because the code checks your current Node.js version and retrieves the abi for version "21.0.0" (which is 120). Therefore, if I use Node.js version 18.18.0, it will use the correct profiling version. It worked!

Yes, that is because we only support even major versions of nodejs as they have long term support as opposed to becoming unsupported after ~6 months.

Major Node.js versions enter Current release status for six months, which gives library authors time to add support for them. After six months, odd-numbered releases (9, 11, etc.) become unsupported, and even-numbered releases (10, 12, etc.) move to Active LTS status and are ready for general use. LTS release status is "long-term support", which typically guarantees that critical bugs will be fixed for a total of 30 months. Production applications should only use Active LTS or Maintenance LTS releases.

Source: https://nodejs.org/en/about/previous-releases

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests