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
Uncaught TypeError: Cannot read property 'getAppPath' of undefined #254
Comments
Are you getting this error in the main or renderer process? You would expect this error if the code in After 1.4.0 the |
It's happening in the renderer process. I'm not sure what I'm doing wrong, as it was working just fine until the update. I did go back and confirm it worked in 1.3.2 and then broke in 1.4.0. Here's what I was doing the init in the renderer process:
I've now changed in the import to |
For 1.4.0 and later, Does your webpack config set |
No, I have this configuration:
That configuration is a work-around for the issues described below. sequelize/sequelize-typescript#717 |
Yep, this will be the cause. In the renderer you're going to have to import the esm build manually. I've not actually tried this myself, but It'll be something like this: import { init } from '@sentry/electron/esm/renderer'
init({}) |
I've tried this, but it doesn't work for me. From digging into webpack stats, it appears that I will need to go through the entire code base and conditionally require the main or renderer module everywhere I load anything related to @sentry/electron, otherwise I end up getting the main process modules in the renderer. I took another pass at it and have something that works, though it definitely feels sub-optimal. Webpack config export const main = {
...
target: 'electron-main',
plugins: [
new webpack.DefinePlugin(
Object.assign({}, replacements, {
__PROCESS_KIND__: JSON.stringify('main'),
})
),
],
})
export const renderer = {
...
target: 'electron-renderer',
// https://github.com/webpack/webpack/issues/7953#issuecomment-538353252
resolve: {
mainFields: ['module', 'main'],
},
plugins: [
new webpack.DefinePlugin(
Object.assign({}, replacements, {
__PROCESS_KIND__: JSON.stringify('ui'),
})
),
],
... Code called by main or renderer import { Severity } from '@sentry/types'
const Sentry =
__PROCESS_KIND__ === 'main'
? require('@sentry/electron/dist/main')
: require('@sentry/electron/dist/renderer') I added a separate import for Severity because Typescript didn't like Sentry.Severity. |
None of the above approaches have worked correctly when including sentry in a preload script (i.e. webpack target Update: my issue was that I had a shared function that I used to init sentry and also configure scope etc. that would take |
@timfish I'm using electron+vue2 |
Have you tried the 3.0.0-beta.1? There has been a significant rewrite to help with issues like this. |
How can I install version |
It's a beta release so it's under the I think you can install it via:
You can't install from git because the git repository doesn't contain the build output. |
@timfish
Also in migration issue #370 in preload script there's a |
Link fixed. I've opened a new issue for errors missing from the preload context: #372 |
Versions + Platform
@sentry/electron@v1.5.1
electron@v7.2.4
Windows
Description
I updated from 0.17.0 to 1.5.1, and I now see this error:
I found a couple of issues (#92, #142) that reference this error, though they seem to be focused on different errors. I tried the deep import mentioned here, to no avail.
This was working with no issues previously, and the only change I made was to update to 1.5.1. I didn't see any breaking changes that suggest a problem in this area.
The text was updated successfully, but these errors were encountered: