ServiceWorker: console.error on empty push event

This commit is contained in:
Alex Gleason 2023-01-05 12:11:04 -06:00
parent 7a14d56f9f
commit 725be075d9
No known key found for this signature in database
GPG key ID: 7211D1F99744FBB7

View file

@ -134,8 +134,10 @@ const htmlToPlainText = (html: string): string =>
/** ServiceWorker `push` event callback. */ /** ServiceWorker `push` event callback. */
const handlePush = (event: PushEvent) => { const handlePush = (event: PushEvent) => {
// If event has no data, stop here. if (!event.data) {
if (!event.data) return; console.error('An empty web push event was received.', { event });
return;
}
const { access_token, notification_id, preferred_locale, title, body, icon } = event.data.json(); const { access_token, notification_id, preferred_locale, title, body, icon } = event.data.json();