Eneris / push-receiver

A library to subscribe to GCM/FCM and receive notifications within a node process.
https://medium.com/@MatthieuLemoine/my-journey-to-bring-web-push-support-to-node-and-electron-ce70eea1c0b0
MIT License
16 stars 16 forks source link

fix: clear heartbeat timeouts when the client is destroyed #8

Closed erikian closed 1 year ago

erikian commented 1 year ago

If the destroy method is called on a client, it keeps trying to send a heartbeat after heartbeatIntervalMs, resulting in a TypeError: Cannot read properties of null (reading 'write') here:

https://github.com/Eneris/push-receiver/blob/a71ceaee715d162096bc478b8d680e44b12e966c/src/client.ts#L246-L249

This fix calls the clearHeartbeat method on destroy to prevent this error.