Cannot import @sentry/electron/main as library for main process
See original GitHub issueVersions + Platform
- [3.0.7] SDK version -
@sentry/electron@v3.0.7
- [17.2.0] Electron version -
electron@v17.2.0
- [MacOS] Platform -
Windows/macOS/Linux
Description
Dear Sentry team,
Currently, when I try to use latest version 3.0.7 and use it for my project, I faced this error below:
And here is my implementation:
import { processTypes } from '../constants';
import isDevEnvironment from './applicationEnvironment';
// eslint-disable-next-line import/no-mutable-exports
let Sentry;
if (process.type === processTypes.renderer) {
Sentry = require('@sentry/electron/renderer');
} else {
Sentry = require('@sentry/electron/main');
}
if (!isDevEnvironment) {
Sentry.init({
debug: isDevEnvironment,
dsn: 'DSN_LINK',
onFatalError: error => {
// Global uncaught errors will be sent to sentry and then the application will exit
console.log('Fatal', error); // eslint-disable-line no-console
process.exit(1);
},
});
}
export { Sentry as default };
May I ask for some help with it?
Many thanks ~
Issue Analytics
- State:
- Created a year ago
- Comments:5
Top Results From Across the Web
Question - ERROR: cannot import the library '_pygimli_'. #140
I properly installed Anaconda ans msys command shell. Then I followed the "Building pyGIMLI from source" procedure. The following message error ...
Read more >Cannot import shared library with g++ - c++ - Stack Overflow
i made a shared library, linked it to a main program, but this main program cannot see any of the shared library methods,...
Read more >Electron | Sentry Documentation
@sentry/electron is the official Sentry SDK for Electron applications. It can capture JavaScript exceptions in the main and renderer processes, as well as ......
Read more >Importing Existing Libraries to Your Connected Workspace in ...
The interface to this process – the Library Importer – presents a one-click solution ... select File » Library Importer from the main...
Read more >Imported Libraries Overview - ADM Help Centers
Business Process Testing: After importing a library, do not change the content of either the existing source library from which a baseline is ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
You are getting the same error because you are still selecting the main/renderer SDK entry point at runtime.
Whenever you check
process.type
this is runtime detection. Your bundler doesn’t know what value to expect and subsequently includes both code paths in the bundle.You need to remove
index.js
completely and call main/renderer from the earliest point in each process.You could use the browser/node SDKs but you’d still have similar issues with bundler + runtime detection and you’d lose all the additional features the Electron SDK adds including:
Hi @timfish, I am not 100% sure I fixed my issue or not, but when I put sentry configuration file as part of entry configuration in webpack, the error is gone …
Something like this. Thanks for help mate 👍