Page MenuHomePhabricator

Cannot read properties of undefined (reading 'then')
Closed, ResolvedPublicPRODUCTION ERROR

Description

Error
Callstack:
at a.performNewSearch  https://commons.wikimedia.org/w/load.php?lang=en&modules=jquery,mediasearch&skin=vector&version=2rz3d:235:50
at Array.<anonymous>  <anonymous>:294:746
at a.dispatch  <anonymous>:296:459
at a.dispatch  <anonymous>:292:122
at a.n.<computed>  <anonymous>:298:777
at a.onTermOrFilterChange  https://commons.wikimedia.org/w/load.php?lang=en&modules=jquery,mediasearch&skin=vector&version=2rz3d:189:881
at allActiveFilters  https://commons.wikimedia.org/w/load.php?lang=en&modules=jquery,mediasearch&skin=vector&version=2rz3d:190:218
at fn.run  <anonymous>:327:738
at un  <anonymous>:325:749
at Array.<anonymous>  <anonymous>:312:430
Impact

The user is unable to search for an empty search term. Clicking the X to clean the result still works

Reproducible steps

Scenario 1

  • Access Special:MediaSearch
  • Search term (eg cat)
  • Wait for the result to show
  • Now manually remove the search term (do not use the X)
  • Search again

Expected

  • The search result should be cleaned up

Actual

  • An error is triggered and the Ui does not change from the previous search

Scenario 2

  • Access Special:MediaSearch
  • Search term (eg cat)
  • Wait for the result to show
  • Now manually remove the search term (do not use the X)
  • Search again (empty result)
  • Change a filter

Expected

  • There should be no errors in the Console

Actual

  • An error is triggered

Scenario 3

  • Access Special:MediaSearch
  • Search term (eg cat)
  • Wait for the result to show
  • Now manually remove the search term (do not use the X)
  • Search again (empty result)
  • Change a Tab

Expected

  • There should be no errors in the Console

Actual

  • An error is triggered

Event Timeline

Change 736723 had a related patch set uploaded (by Simone Cuomo; author: Simone Cuomo):

[mediawiki/extensions/MediaSearch@master] Cannot read properties of undefined (reading 'then')

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

Change 736723 merged by jenkins-bot:

[mediawiki/extensions/MediaSearch@master] Cannot read properties of undefined (reading 'then')

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

Moving back to Ready for Development - the issue is still present in ptoduction.

The most recent timestamp from logstash Nov 23, 2021 @ 16:18:37.375; the number of errors is 299 -a link to the error

Checked the scenarios in the task description on commons wmf.9

  • did not see the Console error for the scenarios 1 and 2
  • scenario 3 still produces the Console error and the steps to reproduce the issue
    • perform an empty search in any tabs - the correct message appears "Search more than 78,978,373..."
    • switch to a different tab - the Console error will be displayed:
VM352:306 TypeError: Cannot read properties of undefined (reading 'then')
    at a.searchMore (load.php?lang=en&modules=jquery,mediasearch&skin=vector&version=lxfwq:235)
    at Array.<anonymous> (<anonymous>:300:746)
    at a.dispatch (<anonymous>:302:459)
    at a.dispatch (<anonymous>:298:122)
    at a.n.<computed> (<anonymous>:304:777)
    at a.getMoreResultsForTabIfAvailable (load.php?lang=en&modules=jquery,mediasearch&skin=vector&version=lxfwq:189)
    at a.currentType (load.php?lang=en&modules=jquery,mediasearch&skin=vector&version=lxfwq:190)
    at fn.run (<anonymous>:334:638)
    at un (<anonymous>:332:645)
    at Array.<anonymous> (<anonymous>:319:333)

Change 741148 had a related patch set uploaded (by Simone Cuomo; author: Simone Cuomo):

[mediawiki/extensions/MediaSearch@master] Cannot read properties of undefined (reading 'then')

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

Change 741148 merged by jenkins-bot:

[mediawiki/extensions/MediaSearch@master] Cannot read properties of undefined (reading 'then')

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

Checked - the number of errors is 25 (after wmf.12was deployed) The most recent timestamp: Dec 9, 2021 @ 21:55:10.004 - https://logstash.wikimedia.org/goto/5c96957d7a6b7c0532a1cd2e055a363c)

I re-checked the scenarios listed in the task description - I cannot trigger the error.

I checked commons wmf.13 - below is the latest error ( "http": "request_headers": are omitted) - https://logstash.wikimedia.org/goto/c31058d772c30fc64494364e1e85b29a. The json output of stack trace mentions vuex - maybe @egardner can provide some insights on why the error is still present?

{
  "_index": "logstash-2021.12.16",
  "_type": "_doc",
  "_id": "PVD7xH0B-N5J53KJVx2i",
  "_version": 1,
  "_score": null,
  "_source": {
    "meta": {
      "domain": "commons.wikimedia.org",
      "stream": "mediawiki.client.error",
      "id": "b6a7b32f-430f-44c2-a7d8-8bbe81b3962c",
      "dt": "2021-12-16T20:42:24.274Z",
      "request_id": "c21284e7-696f-45be-aeee-c255fafac523"
    },
    "message": "TypeError: Cannot read property 'then' of undefined",
    "file_url": "https://commons.wikimedia.org/w/load.php?lang=en&modules=@vue/composition-api,jquery,mediasearch,vue,vuex|ext.centralauth.ForeignApi|mediawiki.ForeignApi|mediawiki.ForeignApi.core|mediawiki.ui.button&skin=vector&version=vpjoo",

    "@timestamp": "2021-12-16T20:42:25.322Z",
    "level": "ERROR",
    "stack_trace": "at a.searchMore  https://commons.wikimedia.org/w/load.php?lang=en&modules=@vue/composition-api,jquery,mediasearch,vue,vuex|ext.centralauth.ForeignApi|mediawiki.ForeignApi|mediawiki.ForeignApi.core|mediawiki.ui.button&skin=vector&version=vpjoo:237:839\nat Array.<anonymous>  https://commons.wikimedia.org/w/load.php?lang=en&modules=@vue/composition-api,jquery,mediasearch,vue,vuex|ext.centralauth.ForeignApi|mediawiki.ForeignApi|mediawiki.ForeignApi.core|mediawiki.ui.button&skin=vector&version=vpjoo:408:746\nat a.dispatch  https://commons.wikimedia.org/w/load.php?lang=en&modules=@vue/composition-api,jquery,mediasearch,vue,vuex|ext.centralauth.ForeignApi|mediawiki.ForeignApi|mediawiki.ForeignApi.core|mediawiki.ui.button&skin=vector&version=vpjoo:410:459\nat Object.dispatch  https://commons.wikimedia.org/w/load.php?lang=en&modules=@vue/composition-api,jquery,mediasearch,vue,vuex|ext.centralauth.ForeignApi|mediawiki.ForeignApi|mediawiki.ForeignApi.core|mediawiki.ui.button&skin=vector&version=vpjoo:406:122\nat https://commons.wikimedia.org/w/load.php?lang=en&modules=@vue/composition-api,jquery,mediasearch,vue,vuex|ext.centralauth.ForeignApi|mediawiki.ForeignApi|mediawiki.ForeignApi.core|mediawiki.ui.button&skin=vector&version=vpjoo:238:69",
    "normalized_message": "TypeError: Cannot read property 'then' of undefined",
    "$schema": "/mediawiki/client/error/1.0.0",
    "type": "clienterror",
    "@version": "1",
    "url": "https://commons.wikimedia.org/wiki/Special:MediaSearch?search=&title=Special:MediaSearch&go=Go&type=audio",
    "tags": [
      "input-kafka-clienterror-codfw",
      "kafka",
      "es",
      "es",
      "throttle-exempt",
      "normalized_message_untrimmed"
    ],
    "error_class": "TypeError"
  },
  "fields": {
    "@timestamp": [
      "2021-12-16T20:42:25.322Z"
    ]
  },
  "highlight": {
    "normalized_message.keyword": [
      "@opensearch-dashboards-highlighted-field@TypeError: Cannot read property 'then' of undefined@/opensearch-dashboards-highlighted-field@"
    ],
    "type": [
      "@opensearch-dashboards-highlighted-field@clienterror@/opensearch-dashboards-highlighted-field@"
    ],
    "meta.domain": [
      "@[email protected]@/opensearch-dashboards-highlighted-field@"
    ],
    "url": [
      "https://commons.wikimedia.org/wiki/@opensearch-dashboards-highlighted-field@Special:MediaSearch@/opensearch-dashboards-highlighted-field@?search=&title=@opensearch-dashboards-highlighted-field@Special:MediaSearch@/opensearch-dashboards-highlighted-field@&go=Go&type=audio"
    ]
  },
  "sort": [
    1639687345322
  ]
}

@Etonkovidova no need to involve eric, I can look at this.

Even if all the error seem the same "then of undefined", they are actually all different. The .then of undefined happens when a promise has failed, no matter what promise!

I will add some better Promise error management so that we have more defined error in the future

Change 748090 had a related patch set uploaded (by Simone Cuomo; author: Simone Cuomo):

[mediawiki/extensions/MediaSearch@master] Make sure all method return a promise

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

@Etonkovidova I'm not seeing any console errors or broken behavior client-side.

In the logs, I see a lot of occurrences of this error at the beginning of the week but only a trickle now. This would be consistent with the roll-out of https://gerrit.wikimedia.org/r/c/mediawiki/extensions/MediaSearch/ /746961.

Screen Shot 2021-12-17 at 8.31.21 AM.png (768×3 px, 186 KB)

I still think we should merge @SimoneThisDot's patch but it should be okay to wait until next week unless there is some other breakage that I'm missing.

Thanks, @egardner and @SimoneThisDot - yes, as I mentioned in https://phabricator.wikimedia.org/T295015#7561795 - there is no Console errors and the number of errors is quite small.

Based that (and on https://phabricator.wikimedia.org/T295015#7561795), I think that it's ok to close the task as Resolved.

Change 748090 merged by jenkins-bot:

[mediawiki/extensions/MediaSearch@master] Make sure all method return a promise

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