sentry-electron icon indicating copy to clipboard operation
sentry-electron copied to clipboard

building @sentry-internal/node-native-stacktrace against the latest stable electron (v38.3.0) fails

Open nikitakot opened this issue 4 months ago • 5 comments

Is there an existing issue for this?

  • [x] I have checked for existing issues https://github.com/getsentry/sentry-javascript/issues
  • [x] I have reviewed the documentation https://docs.sentry.io/
  • [x] I am using the latest SDK release https://github.com/getsentry/sentry-javascript/releases

How do you use Sentry?

Self-hosted/on-premise

Electron SDK Version

7.2.0

Electron Version

38.3.0

What platform are you using?

Windows

Link to Sentry event

No response

Steps to Reproduce

Trying to setup Event Loop Block Detection for my electron app.

Environment: Windows 11, Powershell 7.5.3, node v22.21.0

Isolated repro:

  1. clone the gist https://gist.github.com/nikitakot/b0dcb5c921916c84e5085ba7f9c37916
  2. $ npm i
  3. npx electron-rebuild

Rebuilding the module fails with:

$ npx electron-rebuild
⠋ Building module: @sentry-internal/node-native-stacktrace, Completed: 0

  module.cc
  win_delay_load_hook.cc
     Creating library C:\Users\playground\eventLoopBlockIntegration\node_modules\@sentry-internal\node-native-stacktrace\build\Release\stack-trace.lib and object C:\Users\playground\eventLoopBlockIntegration\node_modules\@sentry-internal\node-native-stacktrace\build\Release\stack-trace.exp
module.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) public: static class v8::MaybeLocal<class v8::Value> __cdecl v8::JSON::Parse(class v8::Local<class v8::Context>,class v8::Local<class v8::String>,class std::optional<class v8::ScriptOrigin>)" (__imp_?Parse@JSON@v8@@SA?AV?$MaybeLocal@VValue@v8@@@2@V?$Local@VContext@v8@@@2@V?$Local@VString@v8@@@2@V?$optional@VScriptOrigin@v8@@@std@@@Z) [C:\Users\playground\eventLoopBlockIntegration\node_modules\@sentry-internal\node-native-stacktrace\build\stack-trace.vcxproj]
C:\Users\playground\eventLoopBlockIntegration\node_modules\@sentry-internal\node-native-stacktrace\build\Release\stack-trace.node : fatal error LNK1120: 1 unresolved externals [C:\Users\playground\eventLoopBlockIntegration\node_modules\@sentry-internal\node-native-stacktrace\build\stack-trace.vcxproj]
Error: `C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Current\Bin\MSBuild.exe` failed with exit code: 1
    at ChildProcess.<anonymous> (C:\Users\playground\eventLoopBlockIntegration\node_modules\node-gyp\lib\build.js:219:23)
    at ChildProcess.emit (node:events:519:28)
    at ChildProcess._handle.onexit (node:internal/child_process:293:12)

✖ Rebuild Failed

An unhandled error occurred inside electron-rebuild
node-gyp failed to rebuild 'C:\Users\playground\eventLoopBlockIntegration\node_modules\@sentry-internal\node-native-stacktrace'

Error: node-gyp failed to rebuild 'C:\Users\playground\eventLoopBlockIntegration\node_modules\@sentry-internal\node-native-stacktrace'
    at ChildProcess.<anonymous> (file:///C:/Users/playground/eventLoopBlockIntegration/node_modules/@electron/rebuild/lib/module-type/node-gyp/node-gyp.js:114:24)
    at ChildProcess.emit (node:events:519:28)
    at ChildProcess._handle.onexit (node:internal/child_process:293:12)

Expected Result

Modules are built successfully and app launches.

Actual Result

Modules built fails and app fails to launch.

nikitakot avatar Oct 21 '25 10:10 nikitakot

ELECTR-33

linear[bot] avatar Oct 21 '25 10:10 linear[bot]

duplicate of this - https://github.com/getsentry/sentry-javascript-node-native-stacktrace/issues/23

nikitakot avatar Oct 21 '25 11:10 nikitakot

It though this was caused by some breaking changes to v8.

I've been waiting for a Node.js release which uses a newer version of v8.

I've just tried Node v25.0.0 and it gives compilation warnings due to deprecations but no build errors (with v8 14.1.146.11-node.10)

Electron v38 uses v8 14.0.365.10 so I need to look into this again because the build errors do appear to be Electron specific 🤔

timfish avatar Oct 21 '25 11:10 timfish

@timfish as a quick fix can't the thread state parsing be moved from v8::JSON::Parse to either entirely to js layer to captureStackTrace or via global->Get(context, v8::String::NewFromUtf8(isolate, "JSON").ToLocalChecked())?

nikitakot avatar Oct 23 '25 13:10 nikitakot

It might be an option but I'd like to know exactly what is causing the build error with this specific version of Electron/v8

timfish avatar Oct 23 '25 16:10 timfish