"Something went wrong while fetching comments" shows when browsing an issue with link to a specific comment

Steps to reproduce:

  1. Open an Incogninto window in Safari/Firefox/Chrome.
  2. Load https://gitlab.com/gitlab-org/gitlab-ce/issues/58499#note_149874737

In Firefox, I didn't see any 500 errors, but I did see 304 codes. I wonder if the XHR caching is confusing the frontend?

image

Findings

  1. The main bug is that handleLocationHash() is called before notesData is set. Causing discussionsPath to be undefined and thus the error.

    This happens when you choose "Show comments only" or "Show history only" as discussion filter and then open a link to a specific note in an issue / MR. The code here attempts to switch you back to "All activity" and then the bug happens.

  2. The other bug is when you're not logged in. For anonymous users we do not have a persisted value for the filter. But the initial selected value here is null instead of 0 for default. So it goes through the process of switching to "All activity" even if "All activity" is the default option for anonymous users.

Edited by Heinrich Lee Yu