Page MenuHomePhabricator

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


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

Sequence of events:

  • All ve/ve-mw files have been executed.
    • immediately created an instance of itself (ve.init.platform = ..)
    • instantiates (this.imageInfoCache = ..)
  • Test files are executing.
  • Test cases for
  • is constructed.
  • is called.
  • getScalablePromise checks ve.init.platform.imageInfoCache. (It exists.)
  • getScalablePromise calls ve.init.platform.imageInfoCache.get.
  • imageInfoCache.get (inherited from mw.ApiResponseCache) calls
  • getRequestPromise assumes 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 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 failure surfaces as follows:

Uncaught TypeError: Cannot read property 'constructor' of undefined

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

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

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.