Use ignoreMethod on cache.delete

This commit is contained in:
dangered wolf 2022-08-20 15:42:12 -04:00
parent 1e637b064d
commit 6a876d48d5
No known key found for this signature in database
GPG key ID: 41E4D37680ED8B58

View file

@ -123,7 +123,7 @@ export const fetchUsingGuest = async (
/* We'll usually only hit this if we get an invalid response from Twitter. /* We'll usually only hit this if we get an invalid response from Twitter.
It's uncommon, but it happens */ It's uncommon, but it happens */
console.error('Unknown error while fetching conversation from API'); console.error('Unknown error while fetching conversation from API');
event && event.waitUntil(cache.delete(guestTokenRequestCacheDummy.clone())); event && event.waitUntil(cache.delete(guestTokenRequestCacheDummy.clone(), { ignoreMethod: true }));
newTokenGenerated = true; newTokenGenerated = true;
continue; continue;
} }
@ -135,14 +135,14 @@ export const fetchUsingGuest = async (
/* Running out of requests within our rate limit, let's purge the cache */ /* Running out of requests within our rate limit, let's purge the cache */
if (remainingRateLimit < 20) { if (remainingRateLimit < 20) {
console.log(`Purging token on this edge due to low rate limit remaining`); console.log(`Purging token on this edge due to low rate limit remaining`);
event && event.waitUntil(cache.delete(guestTokenRequestCacheDummy.clone())); event && event.waitUntil(cache.delete(guestTokenRequestCacheDummy.clone(), { ignoreMethod: true }));
} }
if ( if (
typeof conversation.globalObjects === 'undefined' && typeof conversation.globalObjects === 'undefined' &&
(typeof conversation.errors === 'undefined' || (typeof conversation.errors === 'undefined' ||
conversation.errors?.[0]?.code === conversation.errors?.[0]?.code ===
239) /* TODO: i forgot what code 239 actually is lol */ 239) /* Error 239 = Bad guest token */
) { ) {
console.log('Failed to fetch conversation, got', conversation); console.log('Failed to fetch conversation, got', conversation);
newTokenGenerated = true; newTokenGenerated = true;