Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mod.require is not a function after enable ANR #828

Closed
3 tasks done
PayneFuRC opened this issue Feb 18, 2024 · 7 comments
Closed
3 tasks done

mod.require is not a function after enable ANR #828

PayneFuRC opened this issue Feb 18, 2024 · 7 comments

Comments

@PayneFuRC
Copy link

Is there an existing issue for this?

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

  1. enable main process anr in our company code
init({
  dsn: '__DSN__',
  debug: true,
  onFatalError: () => {},
  integrations: [new Integrations.Anr({ captureStackTrace: true, anrThreshold: 1000 })],
});
  1. compile and webpack
  2. 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
@timfish
Copy link
Collaborator

timfish commented Feb 18, 2024

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.

@PayneFuRC
Copy link
Author

PayneFuRC commented Feb 19, 2024

@timfish I have imported differently for the main/renderer, but it still doesn't work.

@timfish
Copy link
Collaborator

timfish commented Feb 19, 2024

Ah sorry I understand the issue now. This dynamicRequire is used to workaround node compatibility issues but appears to cause issues with webpack.

@PayneFuRC
Copy link
Author

@timfish any progress?

@timfish
Copy link
Collaborator

timfish commented Apr 9, 2024

Removing use of dynamicRequire is a breaking change and has been removed in the next major version (v5) which is currently being worked on.

@timfish
Copy link
Collaborator

timfish commented May 3, 2024

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.

@timfish
Copy link
Collaborator

timfish commented May 21, 2024

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!

@timfish timfish closed this as completed May 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Archived in project
Development

No branches or pull requests

2 participants