Page MenuHomePhabricator

NewImpact: Cannot read properties of undefined (reading 'days')
Closed, ResolvedPublicBUG REPORT

Description

From the JS error logs: NewImpact: Cannot read properties of undefined (reading 'days') (184 last week), triggered by access to Proxy.longestEditingStreakCount

Steps to reproduce:

On mobile:

  • Register a new account
  • Make the first edit of the account on a non-mainspace edit eg: UserPage
  • Navigate to the newcomers homepage

What happens:
The "Last edited" fields shows 53 years ago. The "Longest streak" shows empty as opposite of using the no data character ....

What should happen:
Show the no data character for both data fields ...

Screenshot 2023-02-09 at 19.15.40.png (512×1 px, 51 KB)

See code review comments

Event Timeline

kostajh triaged this task as High priority.Dec 13 2022, 9:34 AM
kostajh subscribed.

We will want to backport the fix this week. It is happening because we are querying the replica DB in ImpactHooks.php, and we need to query the primary DB instead.

Change 867585 had a related patch set uploaded (by Sergio Gimeno; author: Sergio Gimeno):

[mediawiki/extensions/GrowthExperiments@master] [WIP] User impact: read from primary db on post save hook

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

I can consistently reproduce the issue (no matter what type of task) on a user’s first edit using a db replica setup. I think the problem might be in ImpactHooks::userIsInImpactDataCohort

$lastEditTimestamp = $this->userEditTracker->getLatestEditTimestamp( $userIdentity );
if ( !$lastEditTimestamp ) {
  return false;
}

userEditTracker->getLatestEditTimestamp() seems to use the replica db and return false. Since we’re only calling this from an onPageSaveComplete hook maybe it’s fine to assume the user has indeed edited.

Change 867593 had a related patch set uploaded (by Sergio Gimeno; author: Sergio Gimeno):

[mediawiki/extensions/GrowthExperiments@master] [WIP] New impact: assume the user has edited when onPageSaveComplete is called

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

Change 867674 had a related patch set uploaded (by Sergio Gimeno; author: Sergio Gimeno):

[mediawiki/extensions/GrowthExperiments@master] User impact: read edit count from primary db in save complete hook

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

Change 867585 abandoned by Sergio Gimeno:

[mediawiki/extensions/GrowthExperiments@master] [WIP] User impact: read from primary db on post save hook

Reason:

Re-worked in I6bd0daf5e77ca5f1ff82983f830bb01f3acab9cd

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

Change 867593 abandoned by Sergio Gimeno:

[mediawiki/extensions/GrowthExperiments@master] [WIP] New impact: assume the user has edited when onPageSaveComplete is called

Reason:

Re-worked I6bd0daf5e77ca5f1ff82983f830bb01f3acab9cd

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

Sgs changed the task status from Open to In Progress.Dec 14 2022, 10:57 AM
Sgs moved this task from In Progress to Code Review on the Growth-Team (Sprint 0 (Growth Team)) board.

Change 867674 merged by jenkins-bot:

[mediawiki/extensions/GrowthExperiments@master] User impact: read edit count from primary db in save complete hook

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

Change 868052 had a related patch set uploaded (by Gergő Tisza; author: Sergio Gimeno):

[mediawiki/extensions/GrowthExperiments@wmf/1.40.0-wmf.14] User impact: read edit count from primary db in save complete hook

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

Change 868052 merged by jenkins-bot:

[mediawiki/extensions/GrowthExperiments@wmf/1.40.0-wmf.14] User impact: read edit count from primary db in save complete hook

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

Mentioned in SAL (#wikimedia-operations) [2022-12-15T00:05:06Z] <tgr@deploy1002> Synchronized php-1.40.0-wmf.14/extensions/GrowthExperiments/: Backport: [[gerrit:868052|User impact: read edit count from primary db in save complete hook (T324930)]] (duration: 07m 03s)

Etonkovidova subscribed.

Last timestamp Dec 15, 2022 @ 02:24:43.193 - the logstash link.

Still seeing this in 1.40.0-wmf.19 see logstash. I think this should be fixed when gerrit 860987 lands in production since it adds a defensive check for the longestEditingStreakCount but better keep an eye. Same for the error this.data.longestEditingStreak.datePeriod is undefined (logstash).

Still seeing this in 1.40.0-wmf.19 see logstash. I think this should be fixed when gerrit 860987 lands in production since it adds a defensive check for the longestEditingStreakCount but better keep an eye. Same for the error this.data.longestEditingStreak.datePeriod is undefined (logstash).

Thx, @Sgs - I noticed it too. I'll monitor for few days.

Last 7 days - logstash for wmf.20 shows 11 errors (the last timestamp Jan 31, 2023 @ 13:29:33.816).

Re-opened - there seems to be a spike after wmf.21 deployment - logstash wmf.21 - 134 errors (the last timestamp - Feb 3, 2023 @ 16:13:53.597.

Change 887766 had a related patch set uploaded (by Kosta Harlan; author: Kosta Harlan):

[mediawiki/extensions/GrowthExperiments@master] NewImpact: More defensive check for longestEditingStreak.datePeriod.days

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

kostajh moved this task from QA to Code Review on the Growth-Team (Sprint 0 (Growth Team)) board.
kostajh added a subscriber: Sgs.

Change 892897 had a related patch set uploaded (by Kosta Harlan; author: Kosta Harlan):

[mediawiki/extensions/GrowthExperiments@master] ImpactHooks: Refresh impact for any namespace

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

Change 887766 abandoned by Kosta Harlan:

[mediawiki/extensions/GrowthExperiments@master] NewImpact: More defensive check for longestEditingStreak.datePeriod.days

Reason:

Dropped in favor of https://gerrit.wikimedia.org/r/c/mediawiki/extensions/GrowthExperiments/+/892897

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

Change 892897 merged by jenkins-bot:

[mediawiki/extensions/GrowthExperiments@master] ImpactHooks: Refresh impact for any namespace

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

As of March 09 23:59 UTC there were 22 errors in logstash in 24 hours - I'll recheck tomorrow to see if the rate is even lower.

Checked - the rate is 5 errors - the most recent timestamp Mar 9, 2023 @ 23:16:34.156 {F36905594}

Still seeing 27 errors in last 7 days on Special:Homepage 1.40.0-wmf.27. The conditions to reproduce are different though; It seems all the errors are coming from the mobile site. Not sure if we should re-open 887766 or try to find the steps to reproduce it.

Still seeing 27 errors in last 7 days on Special:Homepage 1.40.0-wmf.27. The conditions to reproduce are different though; It seems all the errors are coming from the mobile site. Not sure if we should re-open 887766 or try to find the steps to reproduce it.

Hmm, there are so few, that I am tempted to leave it alone, even if it would be nice to track this down and get the number to zero.

Still seeing 53 errors in last 7 days on Special:Homepage 1.41.0-wmf.12. The conditions to reproduce are different though; It seems all the errors are coming from the mobile site. I'll try to track the mobile code path causing this.