“Illegal invocation” error: sendbeacon() is called without a context
-
I’m using AddThis on my sites.
I also use Sentry, to monitor errors happening in the browsers of my users.I get a lot of errors with the message “Illegal invocation”, at:
https://s7.addthis.com/js/300/addthis_widget.js in n at line 70:127597n=[function(e,t){return navigator.sendBeacon(e,t)},function(e){var t=new Image;return t.src=e,!0}]
I read about it –
The problem is calling sendBeacon() without binding it to a context, usually the navigator. The solution seems to be to do this:navigator.sendBeacon = navigator.sendBeacon.bind(navigator);
before calling sendBeacon().
I don’t know why – the documentation of sendBeacon doesn’t mention the need to bind(). But various articles and SO answers say so.According to my Sentry account, this error happens on Windows 10, on these Browsers:
- The topic ‘“Illegal invocation” error: sendbeacon() is called without a context’ is closed to new replies.