Page MenuHomePhabricator

TypeError: n.closest is not a function
Closed, DeclinedPublic2 Estimated Story Points

Description

The following production error is occurring at a rate of 1,625 errors in the last 7 days.

According to TypeScript, event.target can be null so this likely needs a null check in handleDOMEventIfEligible inside src/index.js

https://logstash.wikimedia.org/goto/e510b1091cd4fb0841f978ab70d2c861

Summary of events

  • We attempted to fix the bug (best guess)
  • It wasn't fixed so we added some logging to understand the bug
  • Additional logging showed us that all errors were in the form "T340081: Unexpected DOM element undefined with nodeType undefined" telling us that the DOM element didn't have an nodeType or tagName
  • Since all DOM elements should have nodeType this suggests the client was non-standard. Since all errors came from Amazon.com we could conclude that this bug didn't impact real users and Jon declined the ticket.

Event Timeline

Volume is high enough for this to be considered high.

Edtadros set the point value for this task to 2.Jun 22 2023, 5:30 PM

Change 935135 had a related patch set uploaded (by Mabualruz; author: Mabualruz):

[mediawiki/extensions/Popups@master] TypeError: n.closest is not a function

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

Change 935135 merged by jenkins-bot:

[mediawiki/extensions/Popups@master] TypeError: n.closest is not a function

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

Can skip QA in production and be verified after deployment.

The error is still occurring, albeit at a much lower rate from a single client. I'll check again tomorrow to see if this could relate to cache.

The error is still occurring at a similar rate.
Since we don't understand this error, this seems like a great application of mw.errorLogger. Perhaps if we can get a change into next release we can seek to fix it next sprint.

var err = new Error( 'T340081' );
err.stack = JSON.stringify( { nodeType, text: node.textContent } );
mw.errorLogger.logError(err, 'webteam')
Jdlrobson lowered the priority of this task from High to Low.Jul 14 2023, 4:12 PM

Looking more closely at the logstash errors, a lot of these errors seem to be originating from an Amazon ISP. I'm a bit suspicious that these might be being triggered programmatically so I'm lowering the priority to low and filtering those from the logstash board.

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

[mediawiki/extensions/Popups@master] Add additional debugging closest bug

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

the patch LGTM
@Jdlrobson just since mw.errorLogger.logError is nothing I used before I have 1 question: where we can check these logs, does it also show in logstash? or a different place?

Change 938944 merged by jenkins-bot:

[mediawiki/extensions/Popups@master] Add additional debugging closest bug

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

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

[mediawiki/extensions/Popups@wmf/1.41.0-wmf.17] Add additional debugging closest bug

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

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

[mediawiki/extensions/Popups@wmf/1.41.0-wmf.18] Add additional debugging closest bug

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

Change 939329 merged by jenkins-bot:

[mediawiki/extensions/Popups@wmf/1.41.0-wmf.17] Add additional debugging closest bug

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

Change 939330 merged by jenkins-bot:

[mediawiki/extensions/Popups@wmf/1.41.0-wmf.18] Add additional debugging closest bug

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

Mentioned in SAL (#wikimedia-operations) [2023-07-18T20:17:54Z] <urbanecm@deploy1002> Started scap: Backport for [[gerrit:939329|Add additional debugging closest bug (T340081)]], [[gerrit:939330|Add additional debugging closest bug (T340081)]], [[gerrit:939331|Fixes: Mobile login watermark large and uncentered (T341812)]]

Mentioned in SAL (#wikimedia-operations) [2023-07-18T20:19:28Z] <urbanecm@deploy1002> urbanecm and jdlrobson: Backport for [[gerrit:939329|Add additional debugging closest bug (T340081)]], [[gerrit:939330|Add additional debugging closest bug (T340081)]], [[gerrit:939331|Fixes: Mobile login watermark large and uncentered (T341812)]] synced to the testservers mwdebug1002.eqiad.wmnet, mwdebug2001.codfw.wmnet, mwdebug2002.codfw.wmnet, mwdebug1001.eqiad.wmnet, and mw-debug kubernetes de

Mentioned in SAL (#wikimedia-operations) [2023-07-18T20:28:22Z] <urbanecm@deploy1002> Finished scap: Backport for [[gerrit:939329|Add additional debugging closest bug (T340081)]], [[gerrit:939330|Add additional debugging closest bug (T340081)]], [[gerrit:939331|Fixes: Mobile login watermark large and uncentered (T341812)]] (duration: 10m 28s)

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

[mediawiki/extensions/Popups@master] Don't log for documentElement (nodeType 9)

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

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

[mediawiki/extensions/Popups@wmf/1.41.0-wmf.17] Don't log for documentElement (nodeType 9)

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

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

[mediawiki/extensions/Popups@wmf/1.41.0-wmf.18] Don't log for documentElement (nodeType 9)

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

Change 939332 merged by jenkins-bot:

[mediawiki/extensions/Popups@wmf/1.41.0-wmf.17] Don't log for documentElement (nodeType 9)

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

Mentioned in SAL (#wikimedia-operations) [2023-07-18T20:52:53Z] <urbanecm@deploy1002> Started scap: Backport for [[gerrit:939332|Don't log for documentElement (nodeType 9) (T340081)]]

Mentioned in SAL (#wikimedia-operations) [2023-07-18T20:54:24Z] <urbanecm@deploy1002> urbanecm and jdlrobson: Backport for [[gerrit:939332|Don't log for documentElement (nodeType 9) (T340081)]] synced to the testservers mwdebug1002.eqiad.wmnet, mwdebug2002.codfw.wmnet, mwdebug2001.codfw.wmnet, mwdebug1001.eqiad.wmnet, and mw-debug kubernetes deployment (accessible via k8s-experimental XWD option)

Mentioned in SAL (#wikimedia-operations) [2023-07-18T21:02:55Z] <urbanecm@deploy1002> Finished scap: Backport for [[gerrit:939332|Don't log for documentElement (nodeType 9) (T340081)]] (duration: 10m 01s)

Change 939333 merged by jenkins-bot:

[mediawiki/extensions/Popups@wmf/1.41.0-wmf.18] Don't log for documentElement (nodeType 9)

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

Mentioned in SAL (#wikimedia-operations) [2023-07-18T21:14:25Z] <urbanecm@deploy1002> Started scap: Backport for [[gerrit:939333|Don't log for documentElement (nodeType 9) (T340081)]]

Mentioned in SAL (#wikimedia-operations) [2023-07-18T21:15:56Z] <urbanecm@deploy1002> jdlrobson and urbanecm: Backport for [[gerrit:939333|Don't log for documentElement (nodeType 9) (T340081)]] synced to the testservers mwdebug2001.codfw.wmnet, mwdebug2002.codfw.wmnet, mwdebug1002.eqiad.wmnet, mwdebug1001.eqiad.wmnet, and mw-debug kubernetes deployment (accessible via k8s-experimental XWD option)

Mentioned in SAL (#wikimedia-operations) [2023-07-18T21:22:08Z] <urbanecm@deploy1002> Finished scap: Backport for [[gerrit:939333|Don't log for documentElement (nodeType 9) (T340081)]] (duration: 07m 42s)

Change 939364 merged by jenkins-bot:

[mediawiki/extensions/Popups@master] Don't log for documentElement (nodeType 9)

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

We have started collecting data to understand this issue better:
https://logstash.wikimedia.org/goto/72d6d18c1fb404a62db3ed8d79bdbf1e (There was a slight hiccup in the logging which I'm filtering from this link)

Since it is no longer being logged to the unknown channel (which we monitor and trigger alerts on) there is no urgency to resolve this right now.

Change 939276 had a related patch set uploaded (by Mabualruz; author: Mabualruz):

[mediawiki/extensions/Popups@master] TypeError: n.closest is not a function - Check if target is jquery object and get the element from it - Fail over to currentTarget in the case target fails in all cases - if it still fails we keep logging an error

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

Jdlrobson updated the task description. (Show Details)

The errors we'll seeing come from Amazon. I've summarized why we should decline this ticket in the task description so we can refer back to it. We can retain the logging for now for future reference to this issue.

Change 939276 abandoned by Mabualruz:

[mediawiki/extensions/Popups@master] TypeError: n.closest is not a function

Reason:

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