This is caused by an upstream bug that has been confirmed in Firefox:
https://bugzilla.mozilla.org/show_bug.cgi?id=1379762#c5
Background
After some debugging, I noticed that certain pages were appearing more often than others with regards to duplicate tokens.
Some examples:
- https://hu.wikipedia.org/wiki/Sablon:A_Sz%C3%ADnh%C3%A1z-_%C3%A9s_Filmm%C5%B1v%C3%A9szeti_Egyetem_2001-ben_oklevelet_szerzett_hallgat%C3%B3i
- https://it.wikipedia.org/wiki/Tutto_pu%C3%B2_succedere_(serie_televisiva)
- https://it.wikipedia.org/wiki/Scuola_normale_superiore
- https://it.wikipedia.org/wiki/Belgio (Ordinamento dello Stato)
Looking at these pages I noticed they had one common problem - links clustered together that could be accidentally clicked.
My theory is that people are accidentally navigating to links and then quickly hitting back. IT seems this behaviour confuses Firefox and it's possibly reloading the Popups code (I'm currently exploring why more)
Replication steps
Note: This can be replicated locally and is not specific to this page
- Visit https://hu.wikipedia.org/wiki/Sablon:A_Sz%C3%ADnh%C3%A1z-_%C3%A9s_Filmm%C5%B1v%C3%A9szeti_Egyetem_2001-ben_oklevelet_szerzett_hallgat%C3%B3i
- Bucket yourself: mw.storage.session.set('mwuser-sessionId', 1059 ) (you can get a token using this script https://gist.github.com/jdlrobson/999ad762eead45fd27a4d6e29aebe9f8 )
- Refresh page
- Filter events in network tab by "beacon"
- Hover over a link and hover off:
- See single beacon event.
- Click a link "accidentally".
- As soon as url changes to new page press keyboard shortcut for back e.g. cmd + left
- notice duplicated events
Visual of replication steps:
SQL queries
Identify problematic pages:
SELECT wiki, event_pageTitleSource, event_namespaceIdSource, event_action, event_linkInteractionToken, COUNT(*) AS events FROM log.Popups_16364296 WHERE timestamp LIKE '201707%' AND event_linkInteractionToken IS NOT NULL GROUP BY event_pageTitleSource, event_linkInteractionToken # userAgent should be identical if the token is HAVING events>1
How to get a stack trace
In console please execute:
var oldLog = mw.eventLog.logEvent; mw.eventLog.logEvent = function(name, data) { console.trace(); oldLog(name, data); }
Stacktrace:
mw.eventLog.logEvent debugger eval code:1:47 handleTrackedEvent/< https://hu.wikipedia.org/w/extensions/EventLogging/modules/ext.eventLogging.subscriber.js:37:4 fire https://hu.wikipedia.org/w/load.php:3148:10 fireWith https://hu.wikipedia.org/w/load.php:3260:7 Deferred/</deferred[tuple[0]] https://hu.wikipedia.org/w/load.php:3350:5 using https://hu.wikipedia.org/w/load.php:12348:7 handleTrackedEvent https://hu.wikipedia.org/w/extensions/EventLogging/modules/ext.eventLogging.subscriber.js:36:3 handler https://hu.wikipedia.org/w/load.php:10965:7 fire https://hu.wikipedia.org/w/load.php:3148:10 fireWith https://hu.wikipedia.org/w/load.php:3260:7 fire https://hu.wikipedia.org/w/load.php:3267:5 track https://hu.wikipedia.org/w/load.php:10941:4 ./src/changeListeners/eventLogging.js/e.exports/< https://hu.wikipedia.org/w/extensions/Popups/resources/dist/index.js:2:10962 ./src/changeListener.js/e.exports/< https://hu.wikipedia.org/w/extensions/Popups/resources/dist/index.js:2:10418 p https://hu.wikipedia.org/w/extensions/Popups/resources/dist/index.js:2:2827 dispatch https://hu.wikipedia.org/wiki/Sablon:A_Sz%C3%ADnh%C3%A1z-_%C3%A9s_Filmm%C5%B1v%C3%A9szeti_Egyetem_2001-ben_oklevelet_szerzett_hallgat%C3%B3i:2:31753 n/</</< https://hu.wikipedia.org/w/extensions/Popups/resources/dist/index.js:2:1017 dispatch https://hu.wikipedia.org/w/extensions/Popups/resources/dist/index.js:2:4469 ./src/actions.js/s.abandon/</< https://hu.wikipedia.org/w/extensions/Popups/resources/dist/index.js:2:9712 then/</</< https://hu.wikipedia.org/w/load.php:3305:30 fire https://hu.wikipedia.org/w/load.php:3148:10 fireWith https://hu.wikipedia.org/w/load.php:3260:7 Deferred/</deferred[tuple[0]] https://hu.wikipedia.org/w/load.php:3350:5 ./src/wait.js/e.exports/< https://hu.wikipedia.org/w/extensions/Popups/resources/dist/index.js:2:35245
mw.eventLog.logEvent() is called three times, but Redux shows only one state change. (EVENT_LOGGED state is triggered only once)
Possible reasons
- Bug in Mozilla Firefox that leads to two load events being fired
- There is a bug in jquery that leads to two load events being fired
- There is a bug in jquery migrate that leads to two load events being fired
ad block or other extension is interferingRuled out - both Sam and piotr do not have any extensions installed- The way we load JS from localStorage leads to double execution of code under certain circumstances