Multiple desktop notifications for single reply

This is on hosted site, using Chrome 47 / Ubuntu.

Steps to reproduce:

  • Enable desktop notifications in Discourse and allow them in Chrome.
  • Open two browser tabs pointing to the same Discourse instances.
  • Wait for someone to reply to one of your topics.

Expected result:

  • Single desktop notification

Actual result:

  • Desktop notification appears, goes away after a few seconds, and then appears again.

I believe this is a Chrome bug, not Discourse, as I have the same issue with other sites that have Chrome notifications…but I could be wrong!


I don’t remember this happening at first… but couldn’t say if it was a new version of Chrome or Discourse that made me see multiple notifications frequently.

@riking is there anything we can do here to stop this from happening?

I would actually classify it as a Discourse bug because we’re the ones triggering two notifications. Each open tab subscribes to a messagebus callback that creates a new notification. Therefore, two open tabs equals two notifications created.

Right now, we’re assigning tags to each notification but all it does is replace the notification that has the same tag which is why we’re seeing the behavior here.

Notification.tag - Web APIs | MDN
The idea of notification tags is that more than one notification can share the same tag, linking them together. One notification can then be programmatically replaced with another to avoid the users’ screen being filled up with a huge number of similar notifications.

Using push notifications through service workers would fix/replace this but without support for a data payload in push yet, it is going to be tricky to implement correctly.


Oh right, another thing that should be done, in addition to what @tgxworld said, is to stop auto-clearing the notification after 10 seconds, as the browser now does that.

Clearing it after 10 seconds causes problems if, e.g. you are watching a full-screen video, where normally notifications are delayed until you exit fullscreen.


Ah ok. Actually the implementation by @riking had a check for the primary tab. So even though we have two tabs open, it’ll only trigger notifications on the “active” tab by setting the values in localStorage. We made some internal changes that broke it :sweat_smile:

Fix is here

Thanks for the bug report @jsha!!


Excellent, thanks for fixing!

1 Like

This topic was automatically closed after 3 days. New replies are no longer allowed.