MatthieuLemoine / electron-push-receiver

A module to bring Web Push support to Electron allowing it to receive notifications from Firebase Cloud Messaging (FCM).
https://medium.com/@MatthieuLemoine/my-journey-to-bring-web-push-support-to-node-and-electron-ce70eea1c0b0
MIT License
191 stars 62 forks source link

Don't send messages to destroyed webContents #11

Open ibash opened 6 years ago

ibash commented 6 years ago

This commit:

  1. Prevents sending messages to destroyed webContents (which result in a crash)
  2. Allows registering multiple webContents for push notifications

We need this because we are listening for notifcations in a specific webContents. If it crashes we create a new one and call setup again, without this change the next push notification that came in would cause a crash.

ibash commented 6 years ago

cc @MatthieuLemoine I tried to make the minimal change to make this work, but I think I'd like to do some refactoring later on to make it s.t. each call to setup is isolated from one another, what do you think?

ibash commented 6 years ago

Hit a weird electron crash, so I removed the call to isDestroyed: https://github.com/electron/electron/issues/11797

ibash commented 6 years ago

Hey it seems like the crash I was experiencing might be unrelated to this project, doing some more digging now...

ibash commented 6 years ago

Okay - the other crash I was getting was https://github.com/electron/electron/issues/11797 I think this change is still needed to prevent the main process from crashing when the webContents that's setup to receive notifications crashes...