Page MenuHomePhabricator

Uncaught Error: Syntax error, unrecognized expression: #/search in at onHashChange
Closed, ResolvedPublic

Description

When visiting https://th.m.wikipedia.org/wiki/%E0%B8%9C%E0%B8%B9%E0%B9%89%E0%B9%83%E0%B8%8A%E0%B9%89:Patsagorn_Y./common.css#/search I get a JS exception.

Error can be traced to https://github.com/wikimedia/mediawiki-extensions-SyntaxHighlight_GeSHi/blob/master/modules/pygments.linenumbers.js

https://logstash.wikimedia.org/goto/3d0d6c2d5994b2a38291b9b5d7ca28a5

at Function.Sizzle.error  https://af.m.wikipedia.org/w/load.php?lang=af&modules=jquery&skin=minerva&version=tqh7e:21:48
at Sizzle.tokenize  https://af.m.wikipedia.org/w/load.php?lang=af&modules=jquery&skin=minerva&version=tqh7e:30:959
at Sizzle.select  https://af.m.wikipedia.org/w/load.php?lang=af&modules=jquery&skin=minerva&version=tqh7e:37:455
at Function.Sizzle  https://af.m.wikipedia.org/w/load.php?lang=af&modules=jquery&skin=minerva&version=tqh7e:11:866
at Function.jQuery.find  https://af.m.wikipedia.org/w/load.php?lang=af&modules=jquery&skin=minerva&version=tqh7e:146:281
at jQuery.fn.init.find  https://af.m.wikipedia.org/w/load.php?lang=af&modules=jquery&skin=minerva&version=tqh7e:41:390
at jQuery.fn.init  https://af.m.wikipedia.org/w/load.php?lang=af&modules=jquery&skin=minerva&version=tqh7e:42:683
at new jQuery.fn.init  https://af.m.wikipedia.org/w/load.php?lang=af&modules=jquery&skin=minerva&version=tqh7e:145:700
at jQuery  https://af.m.wikipedia.org/w/load.php?lang=af&modules=jquery&skin=minerva&version=tqh7e:2:557
at onHashChange  <anonymous>:325:506

Event Timeline

Krinkle added a subscriber: Esanders.
Krinkle subscribed.

https://logstash.wikimedia.org/app/kibana#/doc/logstash-*/logstash-2021.01.08/clienterror/?id=AXbhqSa1uXf9Ge5ZGRMa

Error Cannot find document.

When visiting https://th.m.wikipedia.org/w/index.php?title=%E0%B8%9C%E0%B8%B9%E0%B9%89%E0%B9%83%E0%B8%8A%E0%B9%89:Patsagorn_Y./common.js#search I get a JS exception.

Did it happen direclty on load? I don't see it. Which browser? Logged-in? I tried Firefox/logged-in and Chromium/logged-out.

Also can't reproduce, or see the error in logstash with the link provided

I see the error if the hash is set to #/search

I can't reproduce either anymore, but could before Is it possible gadgets can interfere with Geshi and might be responsible, or could this have been a race condition?

Error Cannot find document.

Yikes looks like the logstash upgrade broke all our links? It does appear to be happening still, albeit at low frequency:
https://logstash.wikimedia.org/goto/3d0d6c2d5994b2a38291b9b5d7ca28a5

Change 655983 had a related patch set uploaded (by Esanders; owner: Esanders):
[mediawiki/extensions/SyntaxHighlight_GeSHi@master] Don't throw an error when location.hash in unparseable

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

I've fixed the links in the task description.

Change 655983 merged by jenkins-bot:
[mediawiki/extensions/SyntaxHighlight_GeSHi@master] Don't throw an error when location.hash in unparseable

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

Krinkle assigned this task to Esanders.

Firefox shows this warning:

⚠️ Empty string passed to getElementById().
  • Without anchor, location.hash is an empty string; with "#" anchor, location.hash is still an empty string; then with "#x" anchor, location.hash becomes #x. Therefore, location.hash is never #.
  • jQuery constructor can work without argument, or null, undefined, empty string, empty array… all these return an empty collection. (reference)

Considering these elements, the simplest alternative code I could make to fix the above warning:

var $line = $( location.hash && document.getElementById( location.hash.slice( 1 ) ) );