Page MenuHomePhabricator

Test failure: Circular dependency between mw.Target and mw.ImageInfoCache
Closed, ResolvedPublic8 Estimated Story Points

Description

When running [[Special:JavaScriptTest/qunit/plain]] with VisualEditor installed, it currently fails during the ve.dm.TransactionProcessor test.

Sequence of events:

  • All ve/ve-mw files have been executed.
    • ve.init.mw.Platform immediately created an instance of itself (ve.init.platform = ..)
    • ve.init.mw.Platform instantiates ve.init.mw.ImageInfoCache (this.imageInfoCache = ..)
  • Test files are executing.
  • Test cases for ve.dm.TransactionProcessor.
  • ve.dm.MWImageNode is constructed.
  • ve.dm.MWImageNode#getScalablePromise is called.
  • getScalablePromise checks ve.init.platform.imageInfoCache. (It exists.)
  • getScalablePromise calls ve.init.platform.imageInfoCache.get.
  • imageInfoCache.get (inherited from mw.ApiResponseCache) calls ve.init.mw.ImageInfoCache#getRequestPromise.
  • getRequestPromise assumes ve.init.target exists, accessing apiRequest.
  • Boom!

This passes in production because the user doesn't initiate these code paths until after Platform and Target have settled.

Other files (e.g. ve.test.utils.js) instantiate their own Target object. The ve.dm.TransactionProcessor test (or something else) should also ensure that a target exists.

Event Timeline

Krinkle raised the priority of this task from to Needs Triage.
Krinkle updated the task description. (Show Details)
Krinkle added subscribers: Krinkle, Catrope.
Jdforrester-WMF set Security to None.
Jdforrester-WMF moved this task from To Triage to Planned Maintenance on the VisualEditor board.
Jdforrester-WMF added a subscriber: Mooeypoo.

While this error is only intermittently reported by Jenkins in the karma-qunit experimental job, this is likely because the build often fails earlier due to current issues with SQLite.

This is consistently failing locally using MediaWiki with VisualEditor installed. Both when running the tests manually in a web browser, and via grunt karma:main from MediaWiki core. As such it would block adoption of Karma as the tests are failing. I don't know why they're passing in PhantomJS. Possibly this test is being skipped or tolerated somehow.

For comparison, on the command line the ve.dm.TransactionProcessor failure surfaces as follows:

Uncaught TypeError: Cannot read property 'constructor' of undefined
ve.init.mw.ImageInfoCache.getRequestPromise
ve.init.mw.ApiResponseCache.processQueue
later

No rush however as there are other blockers on T74063 right now that will take some work to address first.

Change 186548 had a related patch set uploaded (by Alex Monk):
Use mw.Api to run requests rather than our own stuff in ve.init.mw.Target

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

Change 186548 merged by jenkins-bot:
Use mw.Api to run requests rather than our own stuff in ve.init.mw.Target

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

Might be fixed, don't I'm not sure why. The references causing the circular dependency where due to mw-ImageInfoCache using ve.init.platform, which depends on mw.Target, which ships mw.ImageInfoCache. From what I can see, that has not changed.

However, this error may be shadowed by T90916 which showed up in this bug's place. mediawiki-core-qunit-karma is passing at the moment.