Page MenuHomePhabricator

TypeError: $.cookie is not a function
Open, Needs TriagePublicPRODUCTION ERROR

Description

Error
normalized_message
TypeError: $.cookie is not a function
exception.trace
Impact
Notes

Event Timeline

Presumably a dependency issue, something not loading the jquery.cookie module. Happening about four times a day. It's happening on enwiki Special:CreateAccount; we don't run any code there, and in any case we don't use cookies. The modules parameter is ext.centralNotice.geoIP|ext.centralauth.centralautologin|ext.cx.eventlogging.campaigns|ext.eventLogging,navigationTiming,wikimediaEvents|ext.uls.common,compactlinks,interface,preferences,webfonts|jquery|jquery.client,cookie,textSelection|jquery.uls.data|mediawiki.String,Title,Uri,api,base,cldr,cookie,experiments,jqueryMsg,language,storage,user,util,visibleTimeout|mediawiki.editfont.styles|mediawiki.libs.pluralruleparser|mediawiki.page.ready|mediawiki.ui.button|skins.vector.legacy.js|user.defaults so it could be any number of things but CentralAuth looks the likeliest.

The stack trace is not too useful, all anonymous methods. It suggests something is using mw.user.sessionId() without the appropriate dependency.

...which does have the right dependency so I have no idea what's going on here.

This is happening on Special:CreateAccount where on-wiki code is disabled (though browser extensions of course aren't). And only happening there - if something changed $ I'd expect way more / worse breakage.

Change 743469 had a related patch set uploaded (by Jdlrobson; author: Jdlrobson):

[mediawiki/extensions/WikimediaEvents@master] Disable reading depth on special pages

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

This doesn't look like it relates to reading depth to me (it's only happening because of the scale that reading depth runs at). It relates to the user.sessionId function:
https://gerrit.wikimedia.org/g/mediawiki/core/+/39ebbb075d850c07af114b65973368249ffb117e/resources/src/mediawiki.user.js#158

which calls mw.cookie library:

https://gerrit.wikimedia.org/r/plugins/gitiles/mediawiki/core/+/39ebbb075d850c07af114b65973368249ffb117e/resources/src/mediawiki.cookie/index.js

(which has the jquery.cookie dependency)

I think it's fine to disable ReadingDepth on special pages, if we want a quick solution that doesn't solve the root problem: https://gerrit.wikimedia.org/r/c/mediawiki/extensions/WikimediaEvents/+/743469 (ignore me I haven't had my coffee yet. The error is not just on this page.

Do we want a custom error message here to explore this further? Is there any information that would help us understand this error better?

Change 743469 abandoned by Jdlrobson:

[mediawiki/extensions/WikimediaEvents@master] Disable reading depth on special pages

Reason:

Got confused and misunderstood Gergo. Error is actually occurring on all pages so this doesn't help :)

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

Another theory: It could be that there's some URL filtering active on the target machines that filter out any URLs with the phrase .cookie.

We may also want to consider moving to a more modern better maintained alternative e.g. https://github.com/js-cookie/js-cookie

This doesn't look like it relates to reading depth to me (...) The error is not just on this page.

Right, sorry, I forgot to disable the Growth filter. So ~1000 errors per day and a wide range of browsers and call sites.

That seems too much for exotic browser extension / user script issues, but too little for it to be unconditionally broken.

Another theory: It could be that there's some URL filtering active on the target machines that filter out any URLs with the phrase .cookie.

AFAIK ResourceLoader does not execute module code if a dependency failed to load, and here $.cookie is called from mw.cookie and the module containing that does declare jquery.cookie as a dependency.

We may also want to consider moving to a more modern better maintained alternative e.g. https://github.com/js-cookie/js-cookie

Indeed; that's T265703: Replace jquery.cookie with js-cookie in MediaWiki.