Last active
May 22, 2024 10:07
-
-
Save tjenkinson/53b5724bf8112487f6bd797368e02b56 to your computer and use it in GitHub Desktop.
workaround for https://github.com/cloudflare/workerd/issues/698
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// workaround for https://github.com/cloudflare/workerd/issues/698 | |
const originalFetch = globalThis.fetch; | |
globalThis.fetch = async function (...args) { | |
try { | |
return await originalFetch.apply(this, args); | |
} catch (e) { | |
if (!args[1] || typeof args[1] !== 'object') throw e; | |
const unimplementedCacheError = | |
e && typeof e === 'object' && 'message' in e && e.message === "The 'cache' field on 'RequestInitializerDict' is not implemented."; | |
if (!unimplementedCacheError) throw e; | |
const newOpts = { ...args[1] }; | |
delete newOpts.cache; | |
return originalFetch.apply(this, [args[0], newOpts]); | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks, my friend, this workaround fixed my cloudflare worker error. 👍