MatthieuLemoine / electron-push-receiver

A module to bring Web Push support to Electron allowing it to receive notifications from Firebase Cloud Messaging (FCM).

Home Page:https://medium.com/@MatthieuLemoine/my-journey-to-bring-web-push-support-to-node-and-electron-ce70eea1c0b0

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Upgrading to 2.0 introduces crashes

rahenri opened this issue · comments

Here is the stack trace:

Uncaught Exception:
TypeError: Cannot read property 'value' of undefined
at decrypt (/Users/raphael/go/src/github.com/relay/relay/clients/electron/node_modules/push-receiver/src/utils/decrypt/index.js:10:5)
at Client._onDataMessage (/Users/raphael/go/src/github.com/relay/relay/clients/electron/node_modules/push-receiver/src/client.js:175:17)
at Client._onMessage (/Users/raphael/go/src/github.com/relay/relay/clients/electron/node_modules/push-receiver/src/client.js:164:12)
at emitOne (events.js:115:13)
at Parser.emit (events.js:210:7)
at Parser._onGotMessageBytes (/Users/raphael/go/src/github.com/relay/relay/clients/electron/node_modules/push-receiver/src/parser.js:233:10)
at Parser._waitForData (/Users/raphael/go/src/github.com/relay/relay/clients/electron/node_modules/push-receiver/src/parser.js:128:14)
at Parser._onGotMessageSize (/Users/raphael/go/src/github.com/relay/relay/clients/electron/node_modules/push-receiver/src/parser.js:191:12)
at Parser._onGotMessageTag (/Users/raphael/go/src/github.com/relay/relay/clients/electron/node_modules/push-receiver/src/parser.js:155:10)
at Parser._waitForData (/Users/raphael/go/src/github.com/relay/relay/clients/electron/node_modules/push-receiver/src/parser.js:122:14)
at Parser._onData (/Users/raphael/go/src/github.com/relay/relay/clients/electron/node_modules/push-receiver/src/parser.js:78:12)
at emitOne (events.js:115:13)
at TLSSocket.emit (events.js:210:7)
at addChunk (_stream_readable.js:252:12)
at readableAddChunk (_stream_readable.js:239:11)
at TLSSocket.Readable.push (_stream_readable.js:197:10)
at TLSWrap.onread (net.js:589:20)

@rahenri Are you able to reproduce it on every notification ?

I see that on startup everytime, I haven't kept it open any longer than that.

@yurynix raised raised this issue in @ibash's PR in push-receiver. Maybe they have more informations on this

I've been using GCM, and the messages came in non encrypted,
so I just dropped decryption for my use-case.

I wonder what determines whether it's encrypted or not - we've never seen an unencrypted message...
Would totally make sense to check for the crypto-key not being there and return it as is.

Also - every once in a while we get push notifications that we can't decrypt (even though they have keys and everything). We've ended up just dropping these because they were a very small percentage (<0.5% IIRC) of notifications (and our client expects to not get all notifications anyway).

@rahenri Do you use GCM or FCM ?

@MatthieuLemoine I'm using FCM I believe, I'm using Firebase to push those notifications, so that is FCM right?

Any updates on this? I'm on FCM so messages should be encrypted. Can we just drop the messages that can't be decrypted? Once it crashes, it will continue to crash because the same message will be attempted to be parsed next time until we get a brand new token.

@rahenri Yes I think we can just drop these messages.

Could you setup a PR on push-receiver to fix this ?

Yeah, I will give it a shot

Fix released in v2.1.1