Page MenuHomePhabricator

sendBeacon throws an exception in Firefox when event.gif is adblocked
Closed, ResolvedPublic

Description

Steps to reproduce:

  • enable AdBlock Plus in Firefox
  • add a rule for event.gif (Tools/AdBlock Plus/Filter preferences/Custom Filters, add filter group "test", add filter "event.gif")
  • call mw.eventLog.logEvent

Expected result: call returns a failing promise
Actual result: call throws an exception

Apparently navigator.sendBeacon can do that (just like non-CORS AJAX requests) when the URL is blocked by the browser's security policy.

Event Timeline

OSeveno raised the priority of this task from to High.
OSeveno updated the task description. (Show Details)
OSeveno subscribed.

I would appreciate a reply to confirm I created a bug-report the correct way.

I cannot reproduce the problem. With my browser it works correctly. FireFox 34.0.
Which browser do you use? And which Flickr button do you mean? I don't see one.

According to https://commons.wikimedia.org/wiki/Commons:Flickr_files#Uploading_images and https://commons.wikimedia.org/wiki/Commons:Upload_Wizard/Flickr uploading of files directly from Flickr through the UploadWizard should currently be possible for admins and image reviewers only. @OSeveno as far as I can see is neither, so unless that has been changed, the button probably shouldn't be there for them at all? For the record: I'm neither as well and I do NOT have a Flickr button. Selecting a file seems to work well for me (Firefox 32 on Ubuntu).

Thanks for the help.
A screen of the problem:

bitmap.png (679×1 px, 80 KB)

An other screen showing waht happens when I click on the Flickr button.

2015-01-14_150205.png (610×1 px, 32 KB)

PS: I did receive some additional rights recently. I'm now a member of the autopatrollers. And I'm surfing with Cyberfox 35.0 a 64-bits browser built on Firefox (with Gecko).

Gilles subscribed.

Could you please check in the browser's console if a javascript error happens when you click on the "select files" button?

Nothing happened when clicking the button, but there is this even before doing so:

"Exception thrown by ext.uploadWizard.page" load.php:150
"[Exception... "<no message>"  nsresult: "0x805e0006 (<unknown>)"  location: "JS frame :: https://bits.wikimedia.org/commons.wikimedia.org/load.php?debug=false&lang=nl&modules=jquery%2Cmediawiki&only=scripts&skin=vector&version=20150113T190606Z line 4 > eval :: mw.eventLog.sendBeacon< :: line 36"  data: no]" Exception { message: "", result: 2153644038, name: "", filename: "https://bits.wikimedia.org/commons.wikimedia.org/load.php?debug=false&lang=nl&modules=jquery%2Cmediawiki&only=scripts&skin=vector&version=20150113T190606Z line 4 > eval", lineNumber: 36, columnNumber: 0, inner: null, data: null, stack: "mw.eventLog.sendBeacon<@https://bits.wikimedia.org/commons.wikimedia.org/load.php?debug=false&lang=nl&modules=jquery%2Cmediawiki&only=scripts&skin=vector&version=20150113T190606Z line 4 > eval:36:903
mw.eventLog.logEvent@https://bits.wikimedia.org/commons.wikimedia.org/load.php?debug=false&lang=nl&modules=jquery%2Cmediawiki&only=scripts&skin=vector&version=20150113T190606Z line 4 > eval:37:76
EFLP.log@https://bits.wikimedia.org/commons.wikimedia.org/load.php?debug=false&lang=nl&modules=jquery%2Cmediawiki&only=scripts&skin=vector&version=20150113T190606Z line 4 > eval:252:354
EFLP.performStepLog@https://bits.wikimedia.org/commons.wikimedia.org/load.php?debug=false&lang=nl&modules=jquery%2Cmediawiki&only=scripts&skin=vector&version=20150113T190606Z line 4 > eval:252:236
EFLP.logSkippedStep@https://bits.wikimedia.org/commons.wikimedia.org/load.php?debug=false&lang=nl&modules=jquery%2Cmediawiki&only=scripts&skin=vector&version=20150113T190606Z line 4 > eval:252:509
mw.UploadWizard.prototype.moveToStep@https://bits.wikimedia.org/commons.wikimedia.org/load.php?debug=false&lang=nl&modules=jquery%2Cmediawiki&only=scripts&skin=vector&version=20150113T190606Z line 4 > eval:338:36
mw.UploadWizard.prototype.createInterface@https://bits.wikimedia.org/commons.wikimedia.org/load.php?debug=false&lang=nl&modules=jquery%2Cmediawiki&only=scripts&skin=vector&version=20150113T190606Z line 4 > eval:334:95
mw.UploadWizardPage@https://bits.wikimedia.org/commons.wikimedia.org/load.php?debug=false&lang=nl&modules=ext.uploadWizard.page&skin=vector&version=20150113T190607Z&*:1:211
@https://bits.wikimedia.org/commons.wikimedia.org/load.php?debug=false&lang=nl&modules=ext.uploadWizard.page&skin=vector&version=20150113T190607Z&*:1:289
jQuery.Callbacks/fire@https://bits.wikimedia.org/commons.wikimedia.org/load.php?debug=false&lang=nl&modules=jquery%2Cmediawiki&only=scripts&skin=vector&version=20150113T190606Z:45:105
jQuery.Callbacks/self.add@https://bits.wikimedia.org/commons.wikimedia.org/load.php?debug=false&lang=nl&modules=jquery%2Cmediawiki&only=scripts&skin=vector&version=20150113T190606Z:45:663
jQuery.fn.ready@https://bits.wikimedia.org/commons.wikimedia.org/load.php?debug=false&lang=nl&modules=jquery%2Cmediawiki&only=scripts&skin=vector&version=20150113T190606Z:49:39
@https://bits.wikimedia.org/commons.wikimedia.org/load.php?debug=false&lang=nl&modules=ext.uploadWizard.page&skin=vector&version=20150113T190607Z&*:1:260
@https://bits.wikimedia.org/commons.wikimedia.org/load.php?debug=false&lang=nl&modules=ext.uploadWizard.page&skin=vector&version=20150113T190607Z&*:1:64
runScript@https://bits.wikimedia.org/commons.wikimedia.org/load.php?debug=false&lang=nl&modules=jquery%2Cmediawiki&only=scripts&skin=vector&version=20150113T190606Z:161:236
execute/</checkCssHandles@https://bits.wikimedia.org/commons.wikimedia.org/load.php?debug=false&lang=nl&modules=jquery%2Cmediawiki&only=scripts&skin=vector&version=20150113T190606Z:161:721
execute@https://bits.wikimedia.org/commons.wikimedia.org/load.php?debug=false&lang=nl&modules=jquery%2Cmediawiki&only=scripts&skin=vector&version=20150113T190606Z:162:504
mw.loader</<.implement@https://bits.wikimedia.org/commons.wikimedia.org/load.php?debug=false&lang=nl&modules=jquery%2Cmediawiki&only=scripts&skin=vector&version=20150113T190606Z:168:922
@https://bits.wikimedia.org/commons.wikimedia.org/load.php?debug=false&lang=nl&modules=ext.uploadWizard.page&skin=vector&version=20150113T190607Z&*:1:0
" } load.php:150

OSeveno, can you load https://commons.wikimedia.org/wiki/Special:UploadWizard?debug=true and try that again? The error will be easier to read.

Oh, wait - that issue was probably related to the HotCat debacle yesterday...so you might not be able to reproduce anymore.

Hi, the debug link you provided doesn't give me any error reports.
I'm still not able to use the select files button on page https://commons.wikimedia.org/wiki/Special:UploadWizard
It still produces an error message like above.
Wouldn't it be wise to do a roll-back on the introduction of the Flickr button until the problem is solved ?
Using folks like me as unsolicited beta-testers is not a good idea, i.m.o.
I'm willing to help out and test stuff, provided it's optional and I can still continue with my projects.
Surely you can use an unofficial variant of this page to work on the new Flickr button and leave the old page in place until work is finished ?
Just my thoughts.

The key here is stack: "mw.eventLog.sendBeacon + ad blocker or privacy protection extension

I saw a very similar error message: "Exception thrown by ext.uploadWizard.page"

"[Exception... "<no message>"  nsresult: "0x805e0006 (<unknown>)"  location: "JS frame :: https://bits.wikimedia.org/commons.wikimedia.org/load.php?debug=false&lang=en&modules=jquery%2Cmediawiki&only=scripts&skin=vector&version=20150113T190606Z line 4 > eval :: mw.eventLog.sendBeacon< :: line 36"  data: no]" Exception { message: "", result: 2153644038, name: "", filename: "https://bits.wikimedia.org/commons.wikimedia.org/load.php?debug=false&lang=en&modules=jquery%2Cmediawiki&only=scripts&skin=vector&version=20150113T190606Z line 4 > eval", lineNumber: 36, columnNumber: 0, inner: null, data: null, stack: "mw.eventLog.sendBeacon<@https://bits.wikimedia.org/commons.wikimedia.org/load.php?debug=false&lang=en&modules=jquery%2Cmediawiki&only=scripts&skin=vector&version=20150113T190606Z line 4 > eval:36:519
mw.eventLog.logEvent@https://bits.wikimedia.org/commons.wikimedia.org/load.php?debug=false&lang=en&modules=jquery%2Cmediawiki&only=scripts&skin=vector&version=20150113T190606Z line 4 > eval:36:686
EFLP.log@https://bits.wikimedia.org/commons.wikimedia.org/load.php?debug=false&lang=en&modules=jquery%2Cmediawiki&only=scripts&skin=vector&version=20150113T190606Z line 4 > eval:247:1549
EFLP.performStepLog@https://bits.wikimedia.org/commons.wikimedia.org/load.php?debug=false&lang=en&modules=jquery%2Cmediawiki&only=scripts&skin=vector&version=20150113T190606Z line 4 > eval:247:1431
EFLP.logSkippedStep@https://bits.wikimedia.org/commons.wikimedia.org/load.php?debug=false&lang=en&modules=jquery%2Cmediawiki&only=scripts&skin=vector&version=20150113T190606Z line 4 > eval:247:1704
mw.UploadWizard.prototype.moveToStep@https://bits.wikimedia.org/commons.wikimedia.org/load.php?debug=false&lang=en&modules=jquery%2Cmediawiki&only=scripts&skin=vector&version=20150113T190606Z line 4 > eval:331:36
mw.UploadWizard.prototype.createInterface@https://bits.wikimedia.org/commons.wikimedia.org/load.php?debug=false&lang=en&modules=jquery%2Cmediawiki&only=scripts&skin=vector&version=20150113T190606Z line 4 > eval:327:95
mw.UploadWizardPage@https://bits.wikimedia.org/commons.wikimedia.org/load.php?debug=false&lang=en&modules=ext.uploadWizard.page&skin=vector&version=20150113T190607Z&*:1:211
@https://bits.wikimedia.org/commons.wikimedia.org/load.php?debug=false&lang=en&modules=ext.uploadWizard.page&skin=vector&version=20150113T190607Z&*:1:289
jQuery.Callbacks/fire@https://bits.wikimedia.org/commons.wikimedia.org/load.php?debug=false&lang=en&modules=jquery%2Cmediawiki&only=scripts&skin=vector&version=20150113T190606Z:45:105
jQuery.Callbacks/self.add@https://bits.wikimedia.org/commons.wikimedia.org/load.php?debug=false&lang=en&modules=jquery%2Cmediawiki&only=scripts&skin=vector&version=20150113T190606Z:45:663
jQuery.fn.ready@https://bits.wikimedia.org/commons.wikimedia.org/load.php?debug=false&lang=en&modules=jquery%2Cmediawiki&only=scripts&skin=vector&version=20150113T190606Z:49:39
@https://bits.wikimedia.org/commons.wikimedia.org/load.php?debug=false&lang=en&modules=ext.uploadWizard.page&skin=vector&version=20150113T190607Z&*:1:260
@https://bits.wikimedia.org/commons.wikimedia.org/load.php?debug=false&lang=en&modules=ext.uploadWizard.page&skin=vector&version=20150113T190607Z&*:1:64
runScript@https://bits.wikimedia.org/commons.wikimedia.org/load.php?debug=false&lang=en&modules=jquery%2Cmediawiki&only=scripts&skin=vector&version=20150113T190606Z:161:236
execute/</checkCssHandles@https://bits.wikimedia.org/commons.wikimedia.org/load.php?debug=false&lang=en&modules=jquery%2Cmediawiki&only=scripts&skin=vector&version=20150113T190606Z:161:721
execute@https://bits.wikimedia.org/commons.wikimedia.org/load.php?debug=false&lang=en&modules=jquery%2Cmediawiki&only=scripts&skin=vector&version=20150113T190606Z:162:504
mw.loader</<.implement@https://bits.wikimedia.org/commons.wikimedia.org/load.php?debug=false&lang=en&modules=jquery%2Cmediawiki&only=scripts&skin=vector&version=20150113T190606Z:168:922
@https://bits.wikimedia.org/commons.wikimedia.org/load.php?debug=false&lang=en&modules=ext.uploadWizard.page&skin=vector&version=20150113T190607Z&*:1:0
" }

Adblock Plus reports that the following was blocked: https://bits.wikimedia.org/event.gif?%7B%22event%22%3A%7B%22step%22%3A%22tutorial%22%2C%22skipped%22%3Atrue%2C%22flowId%22%3A1421349383817388%7D%2C%22clientValidated%22%3Atrue%2C%22revision%22%3A8851805%2C%22schema%22%3A%22UploadWizardStep%22%2C%22webHost%22%3A%22commons.wikimedia.org%22%2C%22wiki%22%3A%22commonswiki%22%7D;

IMHO failed tracking due to a vigilant anti-tracking software should not cause this kind of issues; the error should be silently dismissed and tracking should be possibly disabled for the user in concern.

Rillke renamed this task from Flickr upload button broke the regular 'Select Files' button at the Commons upload wizard to UploadWizard broken by adblockers and privacy protection programs on Mozilla Firefox.Jan 15 2015, 7:28 PM

Hi, the debug link you provided doesn't give me any error reports.

May you disclose to us which kind of Ad-blocker are you are using?

Tgr renamed this task from UploadWizard broken by adblockers and privacy protection programs on Mozilla Firefox to sendBeacon throws an exception in Firefox when event.gif is adblocked.Jan 15 2015, 8:42 PM
Tgr updated the task description. (Show Details)

IMHO failed tracking due to a vigilant anti-tracking software should not cause this kind of issues; the error should be silently dismissed and tracking should be possibly disabled for the user in concern.

I agree, and this is how I expected EventLogging to behave. It's not always possible to suppress an entry for the aborted request in the browser console, but it certainly should never cause an exception to be thrown, let alone bubble up and compromise other JavaScript functionality.

Could you (or anyone else affected) try running the following snippet in your browser console and report the result?

try { navigator.sendBeacon( '//bits.wikimedia.org/event.gif?foo=bar' ); } catch (e) { console.error(e); }

I tried disabling Adblock Plus on https://commons.wikimedia.org/wiki/Special:UploadWizard
Then I did a browser refresh.
-> This made the Flick button disappear, as well as it enabled me being able to use the Select Mediafiles button.
You may like to know which filter subscriptions I have (with the respective homepages provided by Ad Block Plus) :

Ofcourse the fact that a "simple" browser add-on can (accidentally) make a feature available to me that I shouldn't have access to, raises some concern about the vulnerability of Commons Wikimedia.

In T86680#980264, @ori wrote:

Could you (or anyone else affected) try running the following snippet in your browser console and report the result?

try { navigator.sendBeacon( '//bits.wikimedia.org/event.gif?foo=bar' ); } catch (e) { console.error(e); }

Native Firefox developer tools

Exception { message: "", result: 2153644038, name: "", filename: "debugger eval code", lineNumber: 1, columnNumber: 0, inner: null, data: null, stack: "@debugger eval code:1:6
" }

Firebug

[Exception... "<no message>"  nsresult: "0x805e0006 (<unknown>)"  location: "JS frame :: debugger eval code :: <TOP_LEVEL> :: line 1"  data: no]
debugger eval code
Line 1

And, assuming you're out for a workaround and wonder if this error was cough by try{}catch(ex){} -- running

try { navigator.sendBeacon( '//bits.wikimedia.org/event.gif?foo=bar' ); } catch (ex) { }

and nothing is shown in the console.

I can reproduce with the subscriptions listed by @OSeveno and as @Rillke already confirmed, the exception is correctly trapped by wrapping the navigator.sendBeacon call in a try/catch block.

gerritbot subscribed.

Change 185405 had a related patch set uploaded (by Gilles):
Catch exceptions thrown by navigator.sendBeacon

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

Patch-For-Review

Aklapper raised the priority of this task from High to Unbreak Now!.Jan 16 2015, 2:39 PM

This creates problems and confusion all over the VillagePumps etc.; raising priority.

@Gilles / @ori: Feel free to fix/deploy this ASAP given Andre's previous comment without checking in with me further.

Change 185405 merged by jenkins-bot:
Catch exceptions thrown by navigator.sendBeacon

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

Change 185491 had a related patch set uploaded (by MarkTraceur):
Catch exceptions thrown by navigator.sendBeacon

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

Patch-For-Review

Change 185492 had a related patch set uploaded (by MarkTraceur):
Catch exceptions thrown by navigator.sendBeacon

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

Patch-For-Review

Change 185491 merged by jenkins-bot:
Catch exceptions thrown by navigator.sendBeacon

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

Change 185492 merged by jenkins-bot:
Catch exceptions thrown by navigator.sendBeacon

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

Tgr subscribed.

Mark deployed the fix.

Change 661378 had a related patch set uploaded (by Ottomata; owner: Ottomata):
[mediawiki/extensions/EventLogging@master] Use core.sendBeacon in core.submit to avoid JS errors

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

Change 661378 had a related patch set uploaded (by Ottomata; owner: Ottomata):
[mediawiki/extensions/EventLogging@master] Use core.sendBeacon in core.submit to avoid JS errors

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

Change 661378 merged by jenkins-bot:
[mediawiki/extensions/EventLogging@master] Use core.sendBeacon in core.submit to avoid JS errors

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