Fix said crash safety

This commit is contained in:
dangered wolf 2023-11-10 16:24:47 -05:00
parent 7dac72df79
commit ebb5e5e60d
No known key found for this signature in database
GPG key ID: 41E4D37680ED8B58

View file

@ -223,6 +223,7 @@ export const twitterFetch = async (
newTokenGenerated = true; newTokenGenerated = true;
continue; continue;
} }
try {
/* If we've generated a new token, we'll cache it */ /* If we've generated a new token, we'll cache it */
if (c.executionCtx && newTokenGenerated && activate) { if (c.executionCtx && newTokenGenerated && activate) {
const cachingResponse = new Response(await activate.clone().text(), { const cachingResponse = new Response(await activate.clone().text(), {
@ -232,12 +233,11 @@ export const twitterFetch = async (
} }
}); });
console.log('Caching guest token'); console.log('Caching guest token');
try {
c.executionCtx.waitUntil(cache.put(guestTokenRequestCacheDummy.clone(), cachingResponse)); c.executionCtx.waitUntil(cache.put(guestTokenRequestCacheDummy.clone(), cachingResponse));
}
} catch (error) { } catch (error) {
console.error((error as Error).stack); console.error((error as Error).stack);
} }
}
// @ts-expect-error - We'll pin the guest token to whatever response we have // @ts-expect-error - We'll pin the guest token to whatever response we have
response.guestToken = guestToken; response.guestToken = guestToken;