Page MenuHomePhabricator

TypeError: $(...).closest is not a function
Open, Needs TriagePublicPRODUCTION ERROR

Description

2755 errors in last 7 days
https://logstash.wikimedia.org/goto/158b49feffd9b076754cf12f9e12c688

at getNodeSide
at HTMLDocument.maybeClearSelectProtection 
at HTMLDocument.dispatch  
at elemData.handle

Seems to relate to code in https://gerrit.wikimedia.org/g/mediawiki/core/+/2ed8578ef33b59a6397e9488006e236be488bb06/resources/src/mediawiki.diff/diff.js which uses e.target (which can be NULL if custom events are being used)

Steps to replicate the issue (include links if applicable):

What happens?:

What should have happened instead?:

Software version (on Special:Version page; skip for WMF-hosted wikis like Wikipedia):

Other information (browser name/version, screenshots, etc.):

Event Timeline

Restricted Application changed the subtype of this task from "Bug Report" to "Production Error". · View Herald TranscriptOct 7 2025, 3:55 PM
Restricted Application added a subscriber: Aklapper. · View Herald Transcript

which uses e.target (which can be NULL if custom events are being used)

Firing a mousedown event without a target feels wrong, but maybe that's fine in the JavaScript land. Can we, from the logs, tell where the custom event is coming from?

which uses e.target (which can be NULL if custom events are being used)

Firing a mousedown event without a target feels wrong, but maybe that's fine in the JavaScript land. Can we, from the logs, tell where the custom event is coming from?

event.target could be a text node so I think that's more likely the issue here since you are mixing a native event handler and jQuery code. I think you need to check event.target.nodeType === Node.TEXT_NODE

Change #1194302 had a related patch set uploaded (by Daimona Eaytoy; author: Daimona Eaytoy):

[mediawiki/core@master] diff.js: guard against events without target or text node target

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

I'm still not 100% sure of what could cause this and would appreciate seeing it, but the fix above should do.

Change #1194302 merged by jenkins-bot:

[mediawiki/core@master] diff.js: guard against events without target or text node target

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