handle weird rejected private listings

This commit is contained in:
ntr committed 2023-02-10 17:32:50 +11:00
1 parent 2dbbf75369
commit 19e0376edf
2 files changed
+16 -1

No files matched your search

+15 -1
View File
@@ -111,7 +111,21 @@ export default function createDiscogs(log: Log, pg: Pg) {
if (unlisted) log.info({ unlisted: unlisted, ...wantDetails(want) }, 'missing listings removed');
// preferentially take listings from sellers if we hit req limits
return Bluebird.mapSeries(ids, async id => listing(id, want));
// sometimes we get dodgy listings from discogs that throw perm errors
// we just want to ignore them
const results = await Promise.allSettled(ids.map(id => listing(id, want)));
// @ts-ignore
const validListings = results
.map(r => {
if (r.status === 'fulfilled') return r.value;
if (r.reason.message.includes('rate limited')) throw r.reason;
return null
})
.filter(v => v);
return validListings;
}
async function listing(id, want) {