Skip to content

Occasional ResourceLoader failures like 'Uncaught TypeError: mw.loader.using is not a function' with instances containing tokens #78

@D-Groenewegen

Description

@D-Groenewegen

[Edited]

  • MW 1.39.6
  • FF 2.4.3 (for MW 1.39)
  • $wgParserCacheType = CACHE_NONE;
  • All tokens come with the required id attributes

The issues are (a) that instances that use tokens and content loaded through default-content often fail to initialise and (b) that Sortable.min.js does not always load. It's as if instances are on the whims of a race condition, though sometimes a browser refresh helps to get back to normal. When I leave out the token fields, everything renders fine.

What these issues have in common is that some of the core ResourceLoader modules that FlexForm.general.js or wsinstance.js relies on are unavailable. I've seen the following error messages in the browser's console:

1. Uncaught TypeError: mw.loader.using is not a function

Uncaught TypeError: mw.loader.using is not a function
    getPredefinedOptionsTokenField [...]/extensions/FlexForm/Modules/instances/wsInstance.js:220
    handlePredefinedData [...]/extensions/FlexForm/Modules/instances/wsInstance.js:179
    jQuery 2
    handlePredefinedData [...]/extensions/FlexForm/Modules/instances/wsInstance.js:153
    handleAsJSON [...]/extensions/FlexForm/Modules/instances/wsInstance.js:109
    handleAsJSON [...]/extensions/FlexForm/Modules/instances/wsInstance.js:103
    convertPredefinedToInstances [...]/extensions/FlexForm/Modules/instances/wsInstance.js:118
    wachtff [...]/extensions/FlexForm/Modules/FlexForm.general.js:70
    init [...]/extensions/FlexForm/Modules/instances/wsInstance.js:609
    WsInstance [...]/extensions/FlexForm/Modules/instances/wsInstance.js:613
    startInstance [...]/extensions/FlexForm/Modules/FlexForm.general.js:170
    jQuery 2
    startInstance [...]/extensions/FlexForm/Modules/FlexForm.general.js:156
    ffHoldTillReady [...]/extensions/FlexForm/Modules/ffHoldTillReady.js:29
    ffHoldTillReady [...]/extensions/FlexForm/Modules/ffHoldTillReady.js:43
[wsInstance.js:220:13]([...]/extensions/FlexForm/Modules/instances/wsInstance.js)

Failure to load Sortable.min.js because mw.config.get('wgExtensionAssetsPath') is null

Sometimes this is accompanied by some failure to construct the right URL for Sortable.min.js, which FF then fails to load:

[insert current page url here]/null/FlexForm/Modules/instances/Sortable.min.js?_=1752128891724

which again appears to be a ResourceLoader issue because mw.config.get('wgExtensionAssetsPath') is unable to fetch the patch.

A possible solution

To check for the availability of mw.loader.using, I added a log to ffHoldTillReady.js right after window.mw. As it happens, mw is consistenly available as an object, but mw.loader.using? Sometimes it is, sometimes it is undefined.

When I expanded the condition with an additional check, the instances are loading fine again, as far as I can tell.

if ( window.mw && window.mw.loader.using ) {
   ....
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions