TypeError: Failed to construct 'Notification': Illegal constructor. Use ServiceWorkerRegistration.showNotification() instead.
at https://test.talk.zabanshenas.com/assets/application-f90359a92de40a4e43d63e0189af9256e9f4eae2e14faf72e4f9ef70239f0943.js:12:14605
at h (https://test.talk.zabanshenas.com/assets/ember_jquery-cf9339810550f9c92505dfbb37362c58a4a8a83bcee2d99174547b01c06ed7d3.js:18:1869)
at C (https://test.talk.zabanshenas.com/assets/ember_jquery-cf9339810550f9c92505dfbb37362c58a4a8a83bcee2d99174547b01c06ed7d3.js:18:3255)
at https://test.talk.zabanshenas.com/assets/ember_jquery-cf9339810550f9c92505dfbb37362c58a4a8a83bcee2d99174547b01c06ed7d3.js:18:3745
at e.invoke (https://test.talk.zabanshenas.com/assets/ember_jquery-cf9339810550f9c92505dfbb37362c58a4a8a83bcee2d99174547b01c06ed7d3.js:9:11634)
at e.flush (https://test.talk.zabanshenas.com/assets/ember_jquery-cf9339810550f9c92505dfbb37362c58a4a8a83bcee2d99174547b01c06ed7d3.js:9:10577)
at e.flush (https://test.talk.zabanshenas.com/assets/ember_jquery-cf9339810550f9c92505dfbb37362c58a4a8a83bcee2d99174547b01c06ed7d3.js:9:12677)
at e._end (https://test.talk.zabanshenas.com/assets/ember_jquery-cf9339810550f9c92505dfbb37362c58a4a8a83bcee2d99174547b01c06ed7d3.js:9:17457)
at MutationObserver._boundAutorunEnd (https://test.talk.zabanshenas.com/assets/ember_jquery-cf9339810550f9c92505dfbb37362c58a4a8a83bcee2d99174547b01c06ed7d3.js:9:13591)
Can anyone suggest how I might go about figuring out whatās causing these errors? I have a lot of them in my logs. I donāt have any plugins apart from the official ones and my Discourse is up to date.
Iām also getting a lot of these ones and not sure if theyāre related:
TypeError: Cannot read property 'get' of null
at toggleUserMenu (https://tfk.thefreekick.com/assets/application-33e7747c7d87dbd465e8f058373c19dd40307f27fac4d9dca97d7d2565a1f4a6.js:65:4916)
at https://tfk.thefreekick.com/assets/application-33e7747c7d87dbd465e8f058373c19dd40307f27fac4d9dca97d7d2565a1f4a6.js:68:3525
at t.value (https://tfk.thefreekick.com/assets/application-33e7747c7d87dbd465e8f058373c19dd40307f27fac4d9dca97d7d2565a1f4a6.js:68:3143)
at t.value (https://tfk.thefreekick.com/assets/application-33e7747c7d87dbd465e8f058373c19dd40307f27fac4d9dca97d7d2565a1f4a6.js:68:3448)
at t.value (https://tfk.thefreekick.com/assets/application-33e7747c7d87dbd465e8f058373c19dd40307f27fac4d9dca97d7d2565a1f4a6.js:68:1810)
at i (https://tfk.thefreekick.com/assets/vendor-3eae3eec8fba033cb1b5af6c103a5b8781caa69cf97fe7773ba89ba68980b263.js:5:4897)
at r (https://tfk.thefreekick.com/assets/vendor-3eae3eec8fba033cb1b5af6c103a5b8781caa69cf97fe7773ba89ba68980b263.js:5:4810)
at l (https://tfk.thefreekick.com/assets/vendor-3eae3eec8fba033cb1b5af6c103a5b8781caa69cf97fe7773ba89ba68980b263.js:5:8813)
at i (https://tfk.thefreekick.com/assets/vendor-3eae3eec8fba033cb1b5af6c103a5b8781caa69cf97fe7773ba89ba68980b263.js:5:7736)
at r (https://tfk.thefreekick.com/assets/vendor-3eae3eec8fba033cb1b5af6c103a5b8781caa69cf97fe7773ba89ba68980b263.js:5:7663)
Can I bump this and ask the same question - what is causing these log messages?
This appears as a warning in the logs, but the failed to construct message suggests that it should have been a failure.
Background
Iām trying to find the source of an insidious bug on our live system and just want to be able to tick this off the list as not being the cause.
The issue usually presents itself on desktop with multiple tabs open, something is updated (post, like, message) in another tab and the tab youāre in ādiesā.
Something is causing the browserās message bus to die which results in the topicās footer disappearing and the user is left looking at the last post in the topic with no new notifications automatically appearing.
Finding the source of this is proving difficult. I thought Iād removed the plugin(s) that might be responsible but a couple of users are reporting that the issue is still there.
The only thing that I can see in the logs for the time period when they saw the issue is a number of messages about failing to construct Notification.
What have I found about this?
This post on stackoverflowā¦
ā¦and the referenced chromium bug report, suggests that there is a difference between desktop and mobile Chrome in the way that notifications are handled - and perhaps there is a deprecation issue.
To my untrained eye, it looks like creating a new Notification will work on desktop (but may be deprecated at some point) but will fail on a mobile platform because notifications are implemented differently there.
So if Iām seeing this in the logs, it looks like some desktop code (new Notification) was executed on a device that does not support the creation of notifications in that way - i.e. mobile Chrome.
Indeed, the logs seem to show that the HTTP_USER_AGENT causing this failure are mobile browsers:
Mozilla/5.0 (Linux; Android 8.1.0; Moto G (5)) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3626.105 Mobile Safari/537.36
Mozilla/5.0 (Linux; Android 8.0.0; SAMSUNG SM-A750F Build/R16NW) AppleWebKit/537.36 (KHTML, like Gecko) SamsungBrowser/8.2 Chrome/63.0.3239.111 Mobile Safari/537.36
The only code that I can find in my installation using new Notification is in desktop-notifications.js.es6 in core - in the following sections:
and
Some specific questions
What is causing this warning to appear in the logs?
Can I ignore it?
Would it potentially cause the message bus to fail in the way I described above?
It seems that the bug Iām chasing could well be related to the āFailed to construct Notificationā error.
IF that is the case, I believe that the only place where this piece of code (new Notification) appears is in core Discourse. So it could be a bug in core.
That said, Iām sure more people would be reporting it if this was a problem with core Discourse. So itās more likely a plugin issue that is breaking core.
Can I ask what non-Discourse plugins you have installed? Letās see if we can find some common potential cause outside of core.
I donāt have much data on the āFailed to constructā issue at the moment, but what data I have points to a small group of users/devices that are causing the errors.
I havenāt seen that happen myself but Iām asking if people have experienced that specific issue.
I havenāt really been able to see a pattern of errors from the userās point of view other than just some poor topic loading that Iām seeing myself from time to time but not sure if it is related.
The User Agent is showing mobile browsers in the Env for these warnings, similar to your post above.
Happy to explore further if I can be any help - just not really sure how best to troubleshoot.
I have two discourse forums. This error appears in both. However in one of them I have hundreds of these errors per hour and I think if its because of a plugin, its because of who is online plugin, which is not installed in the other forum.
Getting the same problem on my instance. Sometimes 30-40 times per day.
TypeError: Failed to construct 'Notification': Illegal constructor. Use ServiceWorkerRegistration.showNotification() instead.
at https://swapd.co/assets/application-a9a1b96b84ba77c33f26b7f4974eff035fd81fee0da6503e09f7e84e2d2a6b53.js:12:16333
at h (https://swapd.co/assets/ember_jquery-cf9339810550f9c92505dfbb37362c58a4a8a83bcee2d99174547b01c06ed7d3.js:18:1869)
at C (https://swapd.co/assets/ember_jquery-cf9339810550f9c92505dfbb37362c58a4a8a83bcee2d99174547b01c06ed7d3.js:18:3255)
at https://swapd.co/assets/ember_jquery-cf9339810550f9c92505dfbb37362c58a4a8a83bcee2d99174547b01c06ed7d3.js:18:3745
at e.invoke (https://swapd.co/assets/ember_jquery-cf9339810550f9c92505dfbb37362c58a4a8a83bcee2d99174547b01c06ed7d3.js:9:11634)
at e.flush (https://swapd.co/assets/ember_jquery-cf9339810550f9c92505dfbb37362c58a4a8a83bcee2d99174547b01c06ed7d3.js:9:10577)
at e.flush (https://swapd.co/assets/ember_jquery-cf9339810550f9c92505dfbb37362c58a4a8a83bcee2d99174547b01c06ed7d3.js:9:12677)
at e._end (https://swapd.co/assets/ember_jquery-cf9339810550f9c92505dfbb37362c58a4a8a83bcee2d99174547b01c06ed7d3.js:9:17457)
at MutationObserver._boundAutorunEnd (https://swapd.co/assets/ember_jquery-cf9339810550f9c92505dfbb37362c58a4a8a83bcee2d99174547b01c06ed7d3.js:9:13591)