Page MenuHomePhabricator

flaky qunit test in CentralNotice: Uncaught TypeError: Cannot read property 'timeRemaining' of undefined
Closed, ResolvedPublic

Description

On https://gerrit.wikimedia.org/r/c/mediawiki/extensions/CentralNotice/+/832709 there were two tests failing with the same message, but passed on recheck indicate that the test is flaky.

Full Jenkins output from a test failure: P43438.

Chrome Headless 90.0.4430.212 (Linux x86_64) ERROR
  Uncaught TypeError: Cannot read property 'timeRemaining' of undefined
  at http://localhost:9876/load.php?modules=ext.centralNotice.bannerSequence%2CchoiceData%2Cdisplay%2CgeoIP%2CkvStore%2CstartUp%2CtestFixtures%7Cext.eventLogging%7Cext.eventLogging.debug%7Cjquery.client%2Ccolor%2Ccookie%2ChighlightText%2ClengthLimit%2CmakeCollapsible%2Ctablesorter%2CtextSelection%7Cjquery.makeCollapsible.styles%7Cjquery.tablesorter.styles%7Cmediawiki.ForeignApi%2CString%2CTitle%2CUri%2Capi%2Ccldr%2Ccookie%2Cdeflate%2Cexperiments%2Cinspect%2CjqueryMsg%2Clanguage%2CmessagePoster%2Cqunit-testrunner%2Cstorage%2Ctemplate%2Ctoc%2Cuser%2Cutil%2CvisibleTimeout%2Cwidgets%7Cmediawiki.ForeignApi.core%7Cmediawiki.language.months%2Ctestdata%7Cmediawiki.libs.pluralruleparser%7Cmediawiki.page.ready%7Cmediawiki.rcfilters.filters.ui%7Cmediawiki.template.mustache%7Cmediawiki.widgets.MediaSearch%2CTable%2Cstyles%7Coojs%2Coojs-ui-core%2Coojs-ui-widgets%2Csinonjs%7Coojs-ui-core.icons%2Cstyles%7Coojs-ui-widgets.icons%7Coojs-ui-windows.icons%7Coojs-ui.styles.icons-content%2Cicons-editing-advanced%2Cicons-editing-core%2Cicons-editing-styling%2Cicons-interactions%2Cicons-layout%2Cicons-media%2Cicons-moderation%2Cindicators%7Ctest.CentralNotice%2CEventLogging%2CMediaWiki&version=1148d:925:682
  
  TypeError: Cannot read property 'timeRemaining' of undefined
      at http://localhost:9876/load.php?modules=ext.centralNotice.bannerSequence%2CchoiceData%2Cdisplay%2CgeoIP%2CkvStore%2CstartUp%2CtestFixtures%7Cext.eventLogging%7Cext.eventLogging.debug%7Cjquery.client%2Ccolor%2Ccookie%2ChighlightText%2ClengthLimit%2CmakeCollapsible%2Ctablesorter%2CtextSelection%7Cjquery.makeCollapsible.styles%7Cjquery.tablesorter.styles%7Cmediawiki.ForeignApi%2CString%2CTitle%2CUri%2Capi%2Ccldr%2Ccookie%2Cdeflate%2Cexperiments%2Cinspect%2CjqueryMsg%2Clanguage%2CmessagePoster%2Cqunit-testrunner%2Cstorage%2Ctemplate%2Ctoc%2Cuser%2Cutil%2CvisibleTimeout%2Cwidgets%7Cmediawiki.ForeignApi.core%7Cmediawiki.language.months%2Ctestdata%7Cmediawiki.libs.pluralruleparser%7Cmediawiki.page.ready%7Cmediawiki.rcfilters.filters.ui%7Cmediawiki.template.mustache%7Cmediawiki.widgets.MediaSearch%2CTable%2Cstyles%7Coojs%2Coojs-ui-core%2Coojs-ui-widgets%2Csinonjs%7Coojs-ui-core.icons%2Cstyles%7Coojs-ui-widgets.icons%7Coojs-ui-windows.icons%7Coojs-ui.styles.icons-content%2Cicons-editing-advanced%2Cicons-editing-core%2Cicons-editing-styling%2Cicons-interactions%2Cicons-layout%2Cicons-media%2Cicons-moderation%2Cindicators%7Ctest.CentralNotice%2CEventLogging%2CMediaWiki&version=1148d:291:186
      at Object.<anonymous> (http://localhost:9876/load.php?modules=ext.centralNotice.bannerSequence%2CchoiceData%2Cdisplay%2CgeoIP%2CkvStore%2CstartUp%2CtestFixtures%7Cext.eventLogging%7Cext.eventLogging.debug%7Cjquery.client%2Ccolor%2Ccookie%2ChighlightText%2ClengthLimit%2CmakeCollapsible%2Ctablesorter%2CtextSelection%7Cjquery.makeCollapsible.styles%7Cjquery.tablesorter.styles%7Cmediawiki.ForeignApi%2CString%2CTitle%2CUri%2Capi%2Ccldr%2Ccookie%2Cdeflate%2Cexperiments%2Cinspect%2CjqueryMsg%2Clanguage%2CmessagePoster%2Cqunit-testrunner%2Cstorage%2Ctemplate%2Ctoc%2Cuser%2Cutil%2CvisibleTimeout%2Cwidgets%7Cmediawiki.ForeignApi.core%7Cmediawiki.language.months%2Ctestdata%7Cmediawiki.libs.pluralruleparser%7Cmediawiki.page.ready%7Cmediawiki.rcfilters.filters.ui%7Cmediawiki.template.mustache%7Cmediawiki.widgets.MediaSearch%2CTable%2Cstyles%7Coojs%2Coojs-ui-core%2Coojs-ui-widgets%2Csinonjs%7Coojs-ui-core.icons%2Cstyles%7Coojs-ui-widgets.icons%7Coojs-ui-windows.icons%7Coojs-ui.styles.icons-content%2Cicons-editing-advanced%2Cicons-editing-core%2Cicons-editing-styling%2Cicons-interactions%2Cicons-layout%2Cicons-media%2Cicons-moderation%2Cindicators%7Ctest.CentralNotice%2CEventLogging%2CMediaWiki&version=1148d:1104:512)
      at Function.invoke (http://localhost:9876/load.php?modules=ext.centralNotice.bannerSequence%2CchoiceData%2Cdisplay%2CgeoIP%2CkvStore%2CstartUp%2CtestFixtures%7Cext.eventLogging%7Cext.eventLogging.debug%7Cjquery.client%2Ccolor%2Ccookie%2ChighlightText%2ClengthLimit%2CmakeCollapsible%2Ctablesorter%2CtextSelection%7Cjquery.makeCollapsible.styles%7Cjquery.tablesorter.styles%7Cmediawiki.ForeignApi%2CString%2CTitle%2CUri%2Capi%2Ccldr%2Ccookie%2Cdeflate%2Cexperiments%2Cinspect%2CjqueryMsg%2Clanguage%2CmessagePoster%2Cqunit-testrunner%2Cstorage%2Ctemplate%2Ctoc%2Cuser%2Cutil%2CvisibleTimeout%2Cwidgets%7Cmediawiki.ForeignApi.core%7Cmediawiki.language.months%2Ctestdata%7Cmediawiki.libs.pluralruleparser%7Cmediawiki.page.ready%7Cmediawiki.rcfilters.filters.ui%7Cmediawiki.template.mustache%7Cmediawiki.widgets.MediaSearch%2CTable%2Cstyles%7Coojs%2Coojs-ui-core%2Coojs-ui-widgets%2Csinonjs%7Coojs-ui-core.icons%2Cstyles%7Coojs-ui-widgets.icons%7Coojs-ui-windows.icons%7Coojs-ui.styles.icons-content%2Cicons-editing-advanced%2Cicons-editing-core%2Cicons-editing-styling%2Cicons-interactions%2Cicons-layout%2Cicons-media%2Cicons-moderation%2Cindicators%7Ctest.CentralNotice%2CEventLogging%2CMediaWiki&version=1148d:925:302)
      at Object.proxy [as requestIdleCallback] (eval at createProxy (http://localhost:9876/load.php?modules=ext.centralNotice.bannerSequence%2CchoiceData%2Cdisplay%2CgeoIP%2CkvStore%2CstartUp%2CtestFixtures%7Cext.eventLogging%7Cext.eventLogging.debug%7Cjquery.client%2Ccolor%2Ccookie%2ChighlightText%2ClengthLimit%2CmakeCollapsible%2Ctablesorter%2CtextSelection%7Cjquery.makeCollapsible.styles%7Cjquery.tablesorter.styles%7Cmediawiki.ForeignApi%2CString%2CTitle%2CUri%2Capi%2Ccldr%2Ccookie%2Cdeflate%2Cexperiments%2Cinspect%2CjqueryMsg%2Clanguage%2CmessagePoster%2Cqunit-testrunner%2Cstorage%2Ctemplate%2Ctoc%2Cuser%2Cutil%2CvisibleTimeout%2Cwidgets%7Cmediawiki.ForeignApi.core%7Cmediawiki.language.months%2Ctestdata%7Cmediawiki.libs.pluralruleparser%7Cmediawiki.page.ready%7Cmediawiki.rcfilters.filters.ui%7Cmediawiki.template.mustache%7Cmediawiki.widgets.MediaSearch%2CTable%2Cstyles%7Coojs%2Coojs-ui-core%2Coojs-ui-widgets%2Csinonjs%7Coojs-ui-core.icons%2Cstyles%7Coojs-ui-widgets.icons%7Coojs-ui-windows.icons%7Coojs-ui.styles.icons-content%2Cicons-editing-advanced%2Cicons-editing-core%2Cicons-editing-styling%2Cicons-interactions%2Cicons-layout%2Cicons-media%2Cicons-moderation%2Cindicators%7Ctest.CentralNotice%2CEventLogging%2CMediaWiki&version=1148d:923:584), <anonymous>:1:35)
      at Object.<anonymous> (http://localhost:9876/load.php?modules=ext.centralNotice.bannerSequence%2CchoiceData%2Cdisplay%2CgeoIP%2CkvStore%2CstartUp%2CtestFixtures%7Cext.eventLogging%7Cext.eventLogging.debug%7Cjquery.client%2Ccolor%2Ccookie%2ChighlightText%2ClengthLimit%2CmakeCollapsible%2Ctablesorter%2CtextSelection%7Cjquery.makeCollapsible.styles%7Cjquery.tablesorter.styles%7Cmediawiki.ForeignApi%2CString%2CTitle%2CUri%2Capi%2Ccldr%2Ccookie%2Cdeflate%2Cexperiments%2Cinspect%2CjqueryMsg%2Clanguage%2CmessagePoster%2Cqunit-testrunner%2Cstorage%2Ctemplate%2Ctoc%2Cuser%2Cutil%2CvisibleTimeout%2Cwidgets%7Cmediawiki.ForeignApi.core%7Cmediawiki.language.months%2Ctestdata%7Cmediawiki.libs.pluralruleparser%7Cmediawiki.page.ready%7Cmediawiki.rcfilters.filters.ui%7Cmediawiki.template.mustache%7Cmediawiki.widgets.MediaSearch%2CTable%2Cstyles%7Coojs%2Coojs-ui-core%2Coojs-ui-widgets%2Csinonjs%7Coojs-ui-core.icons%2Cstyles%7Coojs-ui-widgets.icons%7Coojs-ui-windows.icons%7Coojs-ui.styles.icons-content%2Cicons-editing-advanced%2Cicons-editing-core%2Cicons-editing-styling%2Cicons-interactions%2Cicons-layout%2Cicons-media%2Cicons-moderation%2Cindicators%7Ctest.CentralNotice%2CEventLogging%2CMediaWiki&version=1148d:291:17)
      at Function.Deferred (http://localhost:9876/load.php?modules=jquery%7Cmediawiki.base&version=1hmju:51:772)
      at SafeStorage.getExpiryKeys (http://localhost:9876/load.php?modules=ext.centralNotice.bannerSequence%2CchoiceData%2Cdisplay%2CgeoIP%2CkvStore%2CstartUp%2CtestFixtures%7Cext.eventLogging%7Cext.eventLogging.debug%7Cjquery.client%2Ccolor%2Ccookie%2ChighlightText%2ClengthLimit%2CmakeCollapsible%2Ctablesorter%2CtextSelection%7Cjquery.makeCollapsible.styles%7Cjquery.tablesorter.styles%7Cmediawiki.ForeignApi%2CString%2CTitle%2CUri%2Capi%2Ccldr%2Ccookie%2Cdeflate%2Cexperiments%2Cinspect%2CjqueryMsg%2Clanguage%2CmessagePoster%2Cqunit-testrunner%2Cstorage%2Ctemplate%2Ctoc%2Cuser%2Cutil%2CvisibleTimeout%2Cwidgets%7Cmediawiki.ForeignApi.core%7Cmediawiki.language.months%2Ctestdata%7Cmediawiki.libs.pluralruleparser%7Cmediawiki.page.ready%7Cmediawiki.rcfilters.filters.ui%7Cmediawiki.template.mustache%7Cmediawiki.widgets.MediaSearch%2CTable%2Cstyles%7Coojs%2Coojs-ui-core%2Coojs-ui-widgets%2Csinonjs%7Coojs-ui-core.icons%2Cstyles%7Coojs-ui-widgets.icons%7Coojs-ui-windows.icons%7Coojs-ui.styles.icons-content%2Cicons-editing-advanced%2Cicons-editing-core%2Cicons-editing-styling%2Cicons-interactions%2Cicons-layout%2Cicons-media%2Cicons-moderation%2Cindicators%7Ctest.CentralNotice%2CEventLogging%2CMediaWiki&version=1148d:290:993)
      at SafeStorage.clearExpired (http://localhost:9876/load.php?modules=ext.centralNotice.bannerSequence%2CchoiceData%2Cdisplay%2CgeoIP%2CkvStore%2CstartUp%2CtestFixtures%7Cext.eventLogging%7Cext.eventLogging.debug%7Cjquery.client%2Ccolor%2Ccookie%2ChighlightText%2ClengthLimit%2CmakeCollapsible%2Ctablesorter%2CtextSelection%7Cjquery.makeCollapsible.styles%7Cjquery.tablesorter.styles%7Cmediawiki.ForeignApi%2CString%2CTitle%2CUri%2Capi%2Ccldr%2Ccookie%2Cdeflate%2Cexperiments%2Cinspect%2CjqueryMsg%2Clanguage%2CmessagePoster%2Cqunit-testrunner%2Cstorage%2Ctemplate%2Ctoc%2Cuser%2Cutil%2CvisibleTimeout%2Cwidgets%7Cmediawiki.ForeignApi.core%7Cmediawiki.language.months%2Ctestdata%7Cmediawiki.libs.pluralruleparser%7Cmediawiki.page.ready%7Cmediawiki.rcfilters.filters.ui%7Cmediawiki.template.mustache%7Cmediawiki.widgets.MediaSearch%2CTable%2Cstyles%7Coojs%2Coojs-ui-core%2Coojs-ui-widgets%2Csinonjs%7Coojs-ui-core.icons%2Cstyles%7Coojs-ui-widgets.icons%7Coojs-ui-windows.icons%7Coojs-ui.styles.icons-content%2Cicons-editing-advanced%2Cicons-editing-core%2Cicons-editing-styling%2Cicons-interactions%2Cicons-layout%2Cicons-media%2Cicons-moderation%2Cindicators%7Ctest.CentralNotice%2CEventLogging%2CMediaWiki&version=1148d:290:570)
      at http://localhost:9876/load.php?modules=ext.centralNotice.bannerSequence%2CchoiceData%2Cdisplay%2CgeoIP%2CkvStore%2CstartUp%2CtestFixtures%7Cext.eventLogging%7Cext.eventLogging.debug%7Cjquery.client%2Ccolor%2Ccookie%2ChighlightText%2ClengthLimit%2CmakeCollapsible%2Ctablesorter%2CtextSelection%7Cjquery.makeCollapsible.styles%7Cjquery.tablesorter.styles%7Cmediawiki.ForeignApi%2CString%2CTitle%2CUri%2Capi%2Ccldr%2Ccookie%2Cdeflate%2Cexperiments%2Cinspect%2CjqueryMsg%2Clanguage%2CmessagePoster%2Cqunit-testrunner%2Cstorage%2Ctemplate%2Ctoc%2Cuser%2Cutil%2CvisibleTimeout%2Cwidgets%7Cmediawiki.ForeignApi.core%7Cmediawiki.language.months%2Ctestdata%7Cmediawiki.libs.pluralruleparser%7Cmediawiki.page.ready%7Cmediawiki.rcfilters.filters.ui%7Cmediawiki.template.mustache%7Cmediawiki.widgets.MediaSearch%2CTable%2Cstyles%7Coojs%2Coojs-ui-core%2Coojs-ui-widgets%2Csinonjs%7Coojs-ui-core.icons%2Cstyles%7Coojs-ui-widgets.icons%7Coojs-ui-windows.icons%7Coojs-ui.styles.icons-content%2Cicons-editing-advanced%2Cicons-editing-core%2Cicons-editing-styling%2Cicons-interactions%2Cicons-layout%2Cicons-media%2Cicons-moderation%2Cindicators%7Ctest.CentralNotice%2CEventLogging%2CMediaWiki&version=1148d:289:1115

Event Timeline

Aklapper renamed this task from flaky qunit test inn CentralNotice: Uncaught TypeError: Cannot read property 'timeRemaining' of undefined to flaky qunit test in CentralNotice: Uncaught TypeError: Cannot read property 'timeRemaining' of undefined.Sep 20 2022, 9:48 AM

Also happen on AdvandedSearch extension. Is this a generic error or could that be related?

https://gerrit.wikimedia.org/r/c/mediawiki/extensions/AdvancedSearch/+/856069
https://integration.wikimedia.org/ci/job/quibble-vendor-mysql-php74-noselenium-docker/66772/console
https://integration.wikimedia.org/ci/job/quibble-vendor-mysql-php81-noselenium-docker/430/console

09:48:52   Uncaught TypeError: Cannot read property 'timeRemaining' of undefined
09:48:52   at http://localhost:9876/load.php?modules=oojs-ui.styles.icons-editing-styling%2Cicons-interactions%2Cicons-layout%2Cicons-media%2Cicons-moderation%2Cicons-movement%2Cicons-user%2Cicons-wikimedia%2Cindicators%7Cpapaparse%2Crangefix%2Csinonjs%2Cspark-md5%2CtreeDiffer%2Cunicodejs%7Csocket.io%7Ctest.AdvancedSearch%2CCite%2CEventLogging%2CMediaWiki%2CTemplateData%2CTranslate%2CUniversalLanguageSelector%2CVisualEditor&version=13we0:101:682

https://codesearch.wmcloud.org/deployed/?q=timeRemaining&i=nope&files=%5C.js&excludeFiles=&repos=

Change 881385 had a related patch set uploaded (by Wfan; author: Wfan):

[mediawiki/extensions/CentralNotice@master] check deadline exist before get timeRemaining from it to avoid undefined

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

Hmmm maybe we're not mocking mw.requestIdleCallback in a qunit test somewhere where we should, and some recent change to CI has made calls to the original method unreliable? (More detailed explanations in also Gerrit.) Also, I do see this still happening recently, for example, here.

While I'm still unable to run tests locally using npm run qunit, I've made some progress running them in the browser locally under Donut wiki on the fr-dev stack.

To do so:

You can then select "Enable ResourceLoaderDebug", use the "Module" to select only CentralNotice test modules, and set breakpoints in the browser.

The tests run fine in the browser, so I'm still not able to reproduce this issue locally. However, I noticed in the stack trace provided by Jenkins that the we go through the core function SafeStorage.getExpiryKeys(), which does call mw.requestIdleCallback().

Since the Jenkins output disappears quickly, I've copied the most recent failing output here.

Fresh is now working on Donut (the MW instance with CentralNotice on the fr-dev stack).

To run only CentralNotice qunit tests under Fresh use this command:
node_modules/grunt/bin/grunt qunit --qunit-component=CentralNotice

(For details on how to run Fresh on Donut, see T326974#8576819.)

Thanks much!!!

greg lowered the priority of this task from High to Medium.Feb 14 2023, 9:32 PM

The output in question:

mw.loader
  ✔ .using( .., Function callback ) Promise
  ✔ .implement( styles={ "css": [text, ..] } )
  ✔ .addSource()
  ✔ .register() - ES6 support
  ✔ importScript()
  ✔ importStylesheet()
  ✔ Stale response caching - backcompat
TypeError: Cannot read property 'timeRemaining' of undefined
    at http://localhost:9876/load.php?debug=2&modules=mediawiki.storage
    at jQuery.Deferred
    at ConflictableStorage.SafeStorage.getExpiryKeys
    at ConflictableStorage.SafeStorage.clearExpired http://localhost:9876/load.php?debug=2&modules=mediawiki.storage
    at http://localhost:9876/load.php?debug=2&modules=mediawiki.storage

There are two issues here.

  1. ConflictableStorage. part of VE, appears to be running UI code in the background untracked by any tes. Specifically, it is constructing an instance of the private mw.storage.SafeStorage class.
  2. mw.storage in turn is doing gargage collection in the background as of T121646: Document usage policy for LocalStorage in MediaWiki code, which runs even during integrations tests.

Change 891923 had a related patch set uploaded (by Krinkle; author: Krinkle):

[mediawiki/core@master] mediawiki.storage: Disable async GC during integration test

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

Change 891923 merged by jenkins-bot:

[mediawiki/core@master] mediawiki.storage: Disable async GC during integration test

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

Change 881385 abandoned by Umherirrender:

[mediawiki/extensions/CentralNotice@master] Do not just check deadline exist before get timeRemaining from it to avoid undefined

Reason:

Task is resolved by change in core, hopefully only that is needed and this change is not needed.

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

Change 900673 had a related patch set uploaded (by Umherirrender; author: Krinkle):

[mediawiki/core@REL1_39] mediawiki.storage: Disable async GC during integration test

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

Change 900673 merged by jenkins-bot:

[mediawiki/core@REL1_39] mediawiki.storage: Disable async GC during integration test

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