sentry-electron
sentry-electron copied to clipboard
mod.require is not a function after enable ANR
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?
Sentry Saas (sentry.io)
Electron SDK Version
4.17.0
Electron Version
27.2.0
What platform are you using?
MacOS
Link to Sentry event
https://jupiter-ct.sentry.io/discover/desktop-development:da239c05e8f94e2da9c986d56d147597/?field=title&field=event.type&field=project&field=user.display&field=timestamp&field=replayId&homepage=true&name=All+Events&project=1428302&query=&sort=-timestamp&statsPeriod=1h&yAxis=count%28%29
Steps to Reproduce
- enable main process anr in our company code
init({
dsn: '__DSN__',
debug: true,
onFatalError: () => {},
integrations: [new Integrations.Anr({ captureStackTrace: true, anrThreshold: 1000 })],
});
- compile and webpack
- open the app, then there's an error
TypeError: mod.require is not a function
File "main.js", line 48350, col 14, in dynamicRequire
File "main.js", line 43455, col 41, in getWorkerThreads
File "main.js", line 43540, col 22, in _startWorker
I have tried the method in #92, but it still doesn't work.
Expected Result
No error
Actual Result
There's an error
TypeError: mod.require is not a function
File "main.js", line 48350, col 14, in dynamicRequire
File "main.js", line 43455, col 41, in getWorkerThreads
File "main.js", line 43540, col 22, in _startWorker
If you're using a bundler you'll likely need to import differently for the main/renderer: https://docs.sentry.io/platforms/javascript/guides/electron/#bundler-configuration
This will become the default in the next major version.
@timfish I have imported differently for the main/renderer, but it still doesn't work.
Ah sorry I understand the issue now. This dynamicRequire is used to workaround node compatibility issues but appears to cause issues with webpack.
@timfish any progress?
Removing use of dynamicRequire is a breaking change and has been removed in the next major version (v5) which is currently being worked on.
There is a beta available of v5 of the Electron SDK which uses v8 of the JavaScript SDKs. dynamicRequire is no longer used in this version.
v5.0.0 of the Electron SDK has now been released which uses v8 of the JavaScript SDKs with improved ESM support and no use of dynamicRequire.
Feel free to open a new issue if problems still persist!