refined-hacker-news icon indicating copy to clipboard operation
refined-hacker-news copied to clipboard

fix: Gracefully fail when getUserData fetch returns HTTP 503

Open mlazaric opened this issue 3 years ago • 0 comments
trafficstars

I have noticed the same issue described in #102 where the extension is sometimes stuck in the loading wheel phase. After some playing around, it looks like the problem happens when the getUserData fetch returns HTTP response status code 503 which sometimes happens with HackerNews if you refresh quickly or open a lot of links at once. The fetched page looks like this:

image

Because of the 503 page, the resulting topBarElements is empty and actualTopBar is set to undefined which leads to an Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'children') on line 90 of the utils.js file.

Steps to reproduce

  1. Put a breakpoint on line 3080 in file refined-hacker-news.js.
  2. Refresh https://news.ycombinator.com/news a couple of times quickly.
  3. At some point actualTopBar will become undefined.

mlazaric avatar Feb 22 '22 23:02 mlazaric