Page MenuHomePhabricator

"Pending AJAX requests" error from VisualEditor tests
Closed, ResolvedPublic


This flaky failure affected a MediaWiki core commit earlier today at change 577702.

Jenkins build:

DEBUG [middleware:source-files]: Requesting /api.php?action=query&format=json&titles=whee
DEBUG [middleware:source-files]: Fetching /api.php
DEBUG [proxy]: proxying request - /api.php?action=query&format=json&titles=whee to

  ve.ui.MWWikitextStringTransferHandler (Cite)
    ✖ convert
INFO:backend.DevWebServer: … [200]: /api.php?action=query&format=json&titles=whee


  ve.ui.MWWikitextStringTransferHandler (Cite)
    ✖ convert
      HeadlessChrome 73.0.3683 (Linux 0.0.0)
    afterEach failed on convert: Pending AJAX requests: 0 (active: 1)
    Error: Pending AJAX requests: 0 (active: 1)

When querying Codesearch for the whee phrase in files matching test.*js$ the only result is:

QUnit.module( 've.ui.FragmentInspector (MW)'  
QUnit.test( 'Wikitext link inspector' 
				msg: 'Piped link modified',
				name: 'wikitextLink',
				range: new ve.Range( 16 ),
				input: function () {
					this.annotationInput.getTextInputWidget().setValue( 'whee' );

See also:

Event Timeline

I had a quick look and I don't see how this is happening.

For reference, that test simulates opening the link inspector in VE, optionally typing some text into it, and then closing it.

As far as I can tell, the test waits for the inspector to close before it finishes (1), and the inspector aborts any still pending requests while closing (2), and the requests are meticulously kept track of so that they can actually be aborted (3).

  • (1) ve.test.utils.runFragmentInspectorTests: return inspector.teardown( caseItem.actionData || { action: 'done' } )…
  • (2) ve.ui.LinkAnnotationInspector.prototype.getTeardownProcess: this.annotationInput.setAnnotation( null ); which eventually calls OO.ui.mixin.RequestManager.prototype.abortRequest
  • (3) mw.widgets.TitleWidget.prototype.getSuggestionsPromise: note how promiseAbortObject.abort is reassigned

This specific request comes from this line in mw.widgets.TitleWidget.prototype.getSuggestionsPromise: ret = api.get( { action: 'query', titles: query } );.

There is no doubt that the reported QUnit error about untracked HTTP request is an HTTP request from VisualEditor.

I'm happy to help investigate or offer advice on how to do investigate something, but there is not currently a question for me to answer. What is it you'd like me to do?

It is extra hard to get exra data right now as we consistently reproduce it. in CI However this and other infrequent failures together do affect overall CI stability and developer productivity. Having to wait two or three times for 20 minutes, instead of only once quickly makes a big difference in what one can do in a day.

Some general things to perhaps consider if you haven't already:

  • Does the test use Sinon sandboxes for clocks? If so, perhaps they need additional ticks to consistently resolve the promise object in time.
  • Does the result of the ajax request affect the asserted end-result, or is it just a side-effect that has to happen but isn't used? If so, perhaps the mw.Api method or the higher-level getSuggestionsPromise method could be stubbed out.
  • Does the result need to come from the live MW server? If not, consider using Sinon's "Fake server". See mediawiki.api.options.test.js in MediaWiki core for an example. In a nut shell, you'd enable it from the test setup, and then for tests that need it, you'd specify a partial or full request match with a simulated JSON response. This way eliminates any actual XHR requests from being left behind.

@matmarex Hope that helps :)

This is still failing in CI and randomly preventing patches from being reviewed/merged. Latest at for example.

Did not really dive into this ticket, but "Pending AJAX requests", the description and the "QUnit" buzzword remind me of T250305.

Change 597562 had a related patch set uploaded (by Esanders; owner: Esanders):
[mediawiki/extensions/VisualEditor@master] Use fake server for link inspector tests

Change 597562 merged by jenkins-bot:
[mediawiki/extensions/VisualEditor@master] Use fake server for link inspector tests

As we have no way to reliably trigger this, it's hard to determine if it's now fixed…

ppelberg claimed this task.
ppelberg added a subscriber: ppelberg.

As we have no way to reliably trigger this, it's hard to determine if it's now fixed…

Resolving this for now. Please comment if you think something else should be done.