Page MenuHomePhabricator

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


When visiting I get a JS exception.

Error can be traced to

at Function.Sizzle.error
at Sizzle.tokenize
at Function.Sizzle
at Function.jQuery.find
at jQuery.fn.init.find
at jQuery.fn.init
at new jQuery.fn.init
at jQuery
at onHashChange  <anonymous>:325:506

Event Timeline

Krinkle added a subscriber: Esanders.
Krinkle added a subscriber: Krinkle.*/logstash-2021.01.08/clienterror/?id=AXbhqSa1uXf9Ge5ZGRMa

Error Cannot find document.

When visiting 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:

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

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

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 ) ) );