Page MenuHomePhabricator

mw.centralNotice.recordImpression causes exception when centralNotice banners are loaded (with Adblock Plus browser extension)
Closed, ResolvedPublic

Description

Screencast:
Description: I'm getting an empty error message like this two or more times a day since the last week:

{
	"errorMessage": ": ",
	"url": "https://pt.wikipedia.org/static/1.27.0-wmf.5/extensions/CentralNotice/resources/subscribing/ext.centralNotice.display.js",
	"lineNumber": 183,
	"columnNumber": 0,
	"errorObject": {}
}

I got the info above when I accessed
https://pt.wikipedia.org/w/index.php?title=Pr%C3%A1tica&type=revision&diff=43866142&oldid=43262742
for the first time (the error didn't happen after a page reload), in debug mode.
By clicking on the console, I could see that the problematic line was this:

navigator.sendBeacon( url.toString() );

When in production mode, the error is similar, but the URL we get doesn't make it clear that the error comes from centralNotice. E.g.: this was the message I got at
https://pt.wikipedia.org/w/index.php?diff=next&oldid=43209909

{
	"errorMessage": ": ",
	"url": "https://pt.wikipedia.org/w/load.php?debug=false&lang=pt&modules=ext.centralNotice.bannerChoiceData%2CbannerController%7Cext.centralNotice.bannerController.lib%7Cext.centralauth.centralautologin.clearcookie%7Cext.uls.init%2Cinterface%2Cpreferences%2Cwebfonts%7Cext.visualEditor.desktopArticleTarget.init%7Cext.visualEditor.track%2Cve%7Cjquery.byteLength%2Ccookie%2CtabIndex%2Cthrottle-debounce%2Ctipsy%7Cmediawiki.Title%2CUri%2Capi%2Ccldr%2Ccookie%2CjqueryMsg%2Clanguage%2Cuser%7Cmediawiki.language.data%2Cinit%7Cmediawiki.libs.pluralruleparser%7Cmediawiki.page.startup%7Cskins.vector.js%7Cuser.defaults&skin=vector&version=71829dff924d&*",
	"lineNumber": 6,
	"columnNumber": 0,
	"errorObject": {}
}

Usually, the error didn't happen again after a page reload but in the most recent occurrences, it was happening consistently on every page load, both in production and in debug mode.

Browser information

navigator.userAgent > Mozilla/5.0 (X11; Linux x86_64; rv:42.0) Gecko/20100101 Firefox/42.0

Event Timeline

He7d3r created this task.Aug 25 2015, 2:23 PM
He7d3r raised the priority of this task from to Low.
He7d3r updated the task description. (Show Details)
He7d3r added a subscriber: He7d3r.
Restricted Application added a subscriber: Aklapper. · View Herald TranscriptAug 25 2015, 2:23 PM
This comment was removed by Pcoombe.

using Iceweasel/Firefox I got the following error

@He7d3r: Where exactly? I tried with https://pt.wikipedia.org/w/index.php?diff=next&oldid=43209909?debug=true and I don't see anything in the browser itself nor the browser console (Net/JS tabs). Firefox 40 here...

He7d3r added a comment.EditedAug 27 2015, 5:07 PM

This happened again at
https://pt.wikipedia.org/w/index.php?title=Wikip%C3%A9dia:Lua&curid=4058947&diff=43231300&oldid=42672089

{
	"errorMessage": ": ",
	"url": "https://pt.wikipedia.org/w/load.php?debug=false&lang=pt&modules=ext.centralNotice.bannerChoiceData%2CbannerController%7Cext.centralNotice.bannerController.lib%7Cext.centralauth.centralautologin.clearcookie%7Cext.uls.init%2Cinterface%2Cpreferences%2Cwebfonts%7Cext.visualEditor.desktopArticleTarget.init%7Cext.visualEditor.track%2Cve%7Cjquery.byteLength%2Ccookie%2CtabIndex%2Cthrottle-debounce%2Ctipsy%7Cmediawiki.Title%2CUri%2Capi%2Ccldr%2Ccookie%2CjqueryMsg%2Clanguage%2Cuser%7Cmediawiki.language.data%2Cinit%7Cmediawiki.libs.pluralruleparser%7Cmediawiki.page.startup%7Cskins.vector.js%7Cuser.defaults&skin=vector&version=853a0da9bf84&*",
	"lineNumber": 7,
	"columnNumber": 0,
	"errorObject": {}
}

As I mentioned, this didn't hapen after a page reload, so for the second time I was not able to check it again with debug mode enabled and the console open :(

This comment was removed by He7d3r.

Hi! OK, thanks for reporting... Could you send us the details of your browser and operating system, including version numbers? Thanks!!

This comment was removed by He7d3r.
He7d3r updated the task description. (Show Details)Aug 29 2015, 8:39 PM
He7d3r raised the priority of this task from Low to Normal.EditedSep 1 2015, 10:43 AM

This also happend yesterday when I first loaded this page:
https://pt.wikipedia.org/w/index.php?diff=36301487
and today it happened on
https://pt.wikipedia.org/w/index.php?title=Matem%C3%A1tica&curid=1210&action=history (I reloaded 5+ times and the error persisted)

When the line

window.insertBanner( bannerJson );

was executed it returned this:

"[Exception... "<no message>"  nsresult: "0x805e0006 (<unknown>)" location: "JS frame 
:: https://pt.wikipedia.org/static/1.26wmf20/extensions/CentralNotice/modules/ext.centralNotice.bannerController/bannerController.js
:: mw.centralNotice.recordImpression :: line 339"  data: no]"

This is what I saw in the bannerJson:

Object { bannerName: "wlm_2015", bannerHtml: "<style type="text/css"> #cn-toggle-…", campaign: "wlm 2015", category: "wlm2015", autolink: 0, landingPages: Array[1] }

He7d3r renamed this task from Empty error thrown from centralNotice to mw.centralNotice.recordImpression causes exception when many centralNotice banners are loaded.Sep 1 2015, 10:45 AM
He7d3r renamed this task from mw.centralNotice.recordImpression causes exception when many centralNotice banners are loaded to mw.centralNotice.recordImpression causes exception when centralNotice banners for WLM 2015 are loaded.
He7d3r updated the task description. (Show Details)Sep 1 2015, 11:04 AM

@He7d3r, thank you so much for this detailed report, it's hugely appreciated! :)

So far I haven't been able to reproduce the bug, but it looks like it's similar to T86680, in which sendBeacon throws an exception when the link is blocked by AdBlock Plus or something similar.

(Try this search for the error code shown.)

If you're using AdBlock, could you test with it disabled, to see the error persists?

If the error doesn't persist, then we've probably found the cause! Following the other bug, the solution may be just to catch exceptions thrown by sendBeacon.

Thanks so much once again!! :)

AndyRussG added a subscriber: DStrine.
He7d3r added a comment.Sep 1 2015, 1:36 PM

Yep! That seems to be it: the error only happens when Adblock Plus is enabled.

Aklapper renamed this task from mw.centralNotice.recordImpression causes exception when centralNotice banners for WLM 2015 are loaded to mw.centralNotice.recordImpression causes exception when centralNotice banners for WLM 2015 are loaded (with Adblock Plus browser extension).Sep 1 2015, 2:23 PM

I don't understand why we don't see this bug more often, lots of people use Adblock Plus--perhaps it's unusual because it doesn't happen without the EasyPrivacy list enabled.

This seems like a priority to fix, cos it can damage all other JavaScript on the page. Maybe people with Privacy turned on complain disproportionately little.

Maybe we should add more error checking, which will abort processing earlier when Adblock is enabled and stuff is missing?

He7d3r added a comment.Nov 7 2015, 5:38 PM

Maybe we should add more error checking, which will abort processing earlier when Adblock is enabled and stuff is missing?

Yes please! This is still happening a lot...

awight raised the priority of this task from Normal to Unbreak Now!.Nov 7 2015, 5:41 PM

Raising the priority, sorry we haven't gotten to this yet!

Change 251732 had a related patch set uploaded (by AndyRussG):
Wrap sendBeacon in try/catch to prevent AdBlock issue

https://gerrit.wikimedia.org/r/251732

He7d3r updated the task description. (Show Details)Nov 8 2015, 10:12 AM
He7d3r renamed this task from mw.centralNotice.recordImpression causes exception when centralNotice banners for WLM 2015 are loaded (with Adblock Plus browser extension) to mw.centralNotice.recordImpression causes exception when centralNotice banners are loaded (with Adblock Plus browser extension).Nov 8 2015, 10:21 AM

Change 251732 merged by jenkins-bot:
Wrap sendBeacon in try/catch to prevent AdBlock issue

https://gerrit.wikimedia.org/r/251732

The fix for this was deployed last week! Can anyone confirm that the AdBlock-specific problem is gone? Thanks!!!!

Is it possible to force a banner to appear so that this can be tested?

Looks good.

Amazing!! Thanks so much for helping with this :D

AndyRussG closed this task as Resolved.Nov 21 2015, 4:50 PM
atgo removed a subscriber: atgo.Mar 30 2016, 10:03 PM