From 725be075d9cc19ab8e85fa6335285789afd29162 Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Thu, 5 Jan 2023 12:11:04 -0600 Subject: [PATCH] ServiceWorker: console.error on empty push event --- app/soapbox/service-worker/web-push-notifications.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/app/soapbox/service-worker/web-push-notifications.ts b/app/soapbox/service-worker/web-push-notifications.ts index be40aa1832..0cd9370412 100644 --- a/app/soapbox/service-worker/web-push-notifications.ts +++ b/app/soapbox/service-worker/web-push-notifications.ts @@ -134,8 +134,10 @@ const htmlToPlainText = (html: string): string => /** ServiceWorker `push` event callback. */ const handlePush = (event: PushEvent) => { - // If event has no data, stop here. - if (!event.data) return; + if (!event.data) { + console.error('An empty web push event was received.', { event }); + return; + } const { access_token, notification_id, preferred_locale, title, body, icon } = event.data.json();