You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Bug]: Push notification is never shown while a visible tab in the service worker scope does not run the SDK #1536
Since the foregroundWillDisplaypreventDefault() support (160600), the service worker checks for visible window clients before it shows a push notification. If any visible client exists, it broadcasts NotificationWillDisplay and waits for a NotificationWillDisplayResponse with no timeout (shouldPreventNotificationDisplay in src/sw/serviceWorker/ServiceWorker.ts).
clients.matchAll({ type: 'window', includeUncontrolled: true }) returns every same-origin window in scope, including pages that do not load the SDK, or pages where the SDK has not set up its service worker channel. Those pages never answer, so the promise never settles. The push event stays pending, and the notification is never shown.
Steps to reproduce
Register the OneSignal service worker with the default scope (/) and subscribe on a page that loads the SDK.
Open a different page on the same origin that does not load the SDK (for example, a help or admin page), and keep it visible.
Send a push notification to the subscription.
What did you expect to happen?
The notification is shown, as it is when no tab is visible.
Actual behavior
No notification is shown. The service worker logs [SW] 1 visible clients, awaiting preventDefault and never logs a display. Depending on the browser, the push event times out later and a generic "This site has been updated in the background" notification can appear instead.
Notes
A related race exists when two push events arrive close together: the second one overwrites self.notificationDisplayStatus, so the response for the first notification is ignored and the first notification is never shown either.
Activity