diff --git a/packages/profiling-node/src/cpu_profiler.ts b/packages/profiling-node/src/cpu_profiler.ts index a9a6d65ce191..4d75e18ac3dc 100644 --- a/packages/profiling-node/src/cpu_profiler.ts +++ b/packages/profiling-node/src/cpu_profiler.ts @@ -54,6 +54,18 @@ export function importCppBindingsModule(): PrivateV8CpuProfilerBindings { return createdRequire(`${binaryPath}.node`); } + if (process.versions.electron) { + try { + // @electron/rebuild generates the binary in the generic node-gyp directory + return createdRequire('../../build/Release/sentry_cpu_profiler.node'); + } catch (_) { + // eslint-disable-next-line no-console + console.warn( + "Could not find '@sentry/profiling-node' binary. You should use '@electron/rebuild' to rebuild the native module.", + ); + } + } + // We need the fallthrough so that in the end, we can fallback to the dynamic require. // This is for cases where precompiled binaries were not provided, but may have been compiled from source. if (platform === 'darwin') {