machawk1 / Mink

Chrome extension that uses Memento to indicate that a page a user is viewing on the live web has an archived copy and to give the user access to the copy
MIT License
49 stars 3 forks source link

Aggregator fall-through does not work on an HTTP 502 #343

Open machawk1 opened 2 years ago

machawk1 commented 2 years ago

The default aggregator at memgator.cs.odu.edu is currently returning an HTTP 502. The logic for aggregator fall-through uses fetch, which will not invoke the catch to handle the error, thus the flow never resolves.

fetch should be returning a promise. We are returning window.fetch but somehow detection of this broken promise is not caught in the instance of this HTTP status code. Timely handling of this issue is needed before the default aggregator becomes alive again.

machawk1 commented 2 years ago

Maybe because we are using the built built-in aborter in content.js?

return window.fetch(url, options)
  .then(setTimeout(() => { aborter.abort() }, timeout))
  .catch(error => {
    log(`${url} appears to be down, incrementing host counter`)
    log(error)
    hostI += 1
  })
machawk1 commented 2 years ago

The 502 is likely occurring before the AbortController fires, hence no catch.

machawk1 commented 2 years ago

There is nothing in the associated then (when added) that I am able to tell that distinguishes a successful response from a failed (502).

machawk1 commented 2 years ago

XHR is not a solution here, as fetch will only be allowed in manifest v3. (#316)

machawk1 commented 2 years ago

"Fetch detects only network errors. Other errors (4xx, 5xx) should be manually caught and rejected."

machawk1 commented 2 years ago

The ODUCS aggregator is alive again and this issue is not yet fixed. A mock would be useful here for testing.

machawk1 commented 1 year ago

See #316 for some additional work on this front in adapting the extension to MV3.