lemmy-simplified-federation/scripts
rugk 8a282fe1de
fix: properly fallback in case of error/rejection of one detection method
To implement such a fallback mechanism the extension races two promises against each other here, which have these two methods implemented:
e34050284b/src/background/modules/Detect/Mastodon.js (L164)

[Promise.race](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/race) just has the [issue that it also rejects as soon as a promise rejects, i.e. errors](https://stackoverflow.com/questions/70747069/why-does-promise-race-fulfill-with-an-unfulfilled-promise).
That's actually not what we want. That works, as long as the success comes _before_ the error, but if the error is instant (which is nearly always the case here because the JSON API is faster than website scraping), then it fails.

We want to ignore errors. I.e. I found [something like this SO questions asks for](https://stackoverflow.com/questions/37234191/how-do-you-implement-a-racetosuccess-helper-given-a-list-of-promises), which [points to the modern browser-implemented solution](https://stackoverflow.com/a/60274215/5008962) called [`Promise.any`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/any).

Also needs bumping the Firefox version, but that is not a problem, as that version is really old enough to not be supported anymore. :D
2022-06-12 21:13:25 +02:00
..
manifests fix: properly fallback in case of error/rejection of one detection method 2022-06-12 21:13:25 +02:00
make.sh Exclude GitHub metadata dir from build 2020-03-20 16:46:54 +01:00