question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Exception from outdated electron-config module on newer version of Electron

See original GitHub issue

I’m using Electron 16.0.4 and am initializing the electron-push-receiver from the isolated context preload script in the renderer process. I’m getting this error on importing the module:

TypeError: Cannot read properties of undefined (reading 'app')
    at new ElectronConfig (webpack-internal:///../node_modules/electron-config/index.js:8:47)
    at eval (webpack-internal:///../node_modules/electron-push-receiver/src/index.js:12:16)

It appears that v1.0 of electron-config is making a check: electron.app || electron.remote.app. This throws since both are null in newer versions of Electron. It appears the new package for storing data is electron-store. I think it might be fixed just by updating to use that instead.

I was able to work around this by using the literal strings when listening for the push events rather than trying to import the values in the preload script.

"PUSH_RECEIVER:::START_NOTIFICATION_SERVICE"
"PUSH_RECEIVER:::NOTIFICATION_SERVICE_ERROR"
"PUSH_RECEIVER:::NOTIFICATION_SERVICE_STARTED"
"PUSH_RECEIVER:::NOTIFICATION_SERVICE_ERROR"
"PUSH_RECEIVER:::NOTIFICATION_RECEIVED"
"PUSH_RECEIVER:::TOKEN_UPDATED"

Issue Analytics

  • State:open
  • Created 2 years ago
  • Reactions:2
  • Comments:5

github_iconTop GitHub Comments

1reaction
weeks6commented, Mar 25, 2022

@vialoh Thanks! That helped me a great deal!

0reactions
vialohcommented, Mar 25, 2022

@weeks6 Sure! I’m using @capacitor-community/electron, and you can see how I’ve integrated electron-push-receiver here in this commit: https://github.com/molecule-dev/molecule-app/commit/762188931c98f2835718e147abd4a5c934af555c

And if you’re curious as to how it’s integrated into a React app: https://github.com/molecule-dev/molecule-app/commit/b4b94cd9c31e559dc250835dfb099b1ac008b59e

Plus some instructions for configuring the GOOGLE_CLOUD_MESSAGING_SENDER_ID: https://github.com/molecule-dev/molecule-app/commit/dd767c87625448c0ca5e19378b202379c429453a

The molecule-dev/molecule-app is a work in progress which often has its git history overwritten (for good reason if you take a look at what it’s for), so if these links to the commits above ever break, ping me here and I’ll update this comment.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Native modules that include nan.h fail to build on electron 20 ...
The presence of the deprecated AccessorSignatures specifically is why your module is failing to build. We'll need to get that upstream PR merged ......
Read more >
Breaking Changes | Electron
The remote module is deprecated in Electron 12, and will be removed in Electron 14. It is replaced by the @electron/remote module. //...
Read more >
node module version conflict when installing ... - Stack Overflow
When this type of version mismatch occurs, you can either choose an electron distribution with the target Node version or rebuild the npm...
Read more >
Electron target version - Haxe - OpenFL Community
openfl build electron currently creates files (and node module structure) for Electron v9.1.0 which is kinda outdated (2 years old, Electron ...
Read more >
electron-reload - npm
Simplest way to reload an electron app on file changes!. Latest version: 2.0.0-alpha.1, last published: a year ago.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found