Fixed delayed fetch & improved logging

This commit is contained in:
dakedres 2024-02-10 18:21:13 -07:00
parent ce6e5a0d56
commit 86e16fc56f

11
lib.js
View File

@ -110,13 +110,14 @@ export async function fetchRss(source) {
} catch(err) { } catch(err) {
error = err error = err
} }
source.errored = error !== undefined || !response.ok source.errored = error !== undefined || !response.ok
if(source.errored) { if(source.errored) {
source.error = error ?? createNetworkingError(response) source.error = error ?? createNetworkingError(response)
source.rss = '' source.rss = ''
} else { } else {
source.rss = await response.text() source.rss = await response.text()
console.log(`Found ${source.name} at ${hostname}`)
} }
return source return source
@ -130,11 +131,11 @@ export const delayedFetch = async (url, options, courtesyWait = 5 * 1000) => {
let now = Date.now() let now = Date.now()
if(timeout == null || timeout <= now) { if(timeout == null || timeout <= now) {
waitingList.set(domain, timeout + courtesyWait)
} else { } else {
await sleep(timeout - now) await sleep(timeout - now)
} }
waitingList.set(domain, now + courtesyWait)
return await fetch(url, options) return await fetch(url, options)
} }
@ -655,6 +656,12 @@ export const nitter = {
// https://mastodon.social/@brownpau.rss (note the "@")" // https://mastodon.social/@brownpau.rss (note the "@")"
// - https://mastodon.social/@brownpau/100523448408374430 // - https://mastodon.social/@brownpau/100523448408374430
export const mastodon = {
createSource(user, instances, courtesyWait, postReducerCallback, cache) {
}
}
export const platforms = { export const platforms = {
tumblr, tumblr,
nitter nitter