axiomhq / axiom-js

Official language bindings and library extensions for Axiom
https://axiom.co
MIT License
100 stars 15 forks source link

CloudFlare Workers Error: `Error: The 'cache' field on 'RequestInitializerDict' is not implemented.` #242

Open harrismcc opened 1 week ago

harrismcc commented 1 week ago

When running in a cloudflare worker, I'm getting the following error when attempting to call axiom.flush(): Error: The 'cache' field on 'RequestInitializerDict' is not implemented.

Looking at the stack trace is pointing me to this line: https://github.com/axiomhq/axiom-js/blob/2056f7791fe10f3ffd7516ae4456246714285067/packages/js/src/fetchClient.ts#L32

Cloudflare recently had a compatibility flag become default involving this https://developers.cloudflare.com/workers/configuration/compatibility-flags/#enable-cache-no-store-http-standard-api so maybe something broke?

Is there something actually broken here, or is this some kind of misconfiguration on my end? Thanks!

harrismcc commented 1 week ago

With a bit of testing and some node_modules surgery, I can confirm that when either commenting out that line, or changing it to no-store it works again.

It seems like this might be an upstream cloudflare issue https://github.com/cloudflare/workerd/issues/698

But maybe adding an option where the cache could be toggled off would fix this, at least until cloudflare fixes the root issue?

harrismcc commented 1 week ago

Just heard from the Cloudflare folks and it seems like support for no-cache is in the works, but not compatible yet. no-store however works, so another fix (that wouldn't require a new config option) would be to swap out no-cache for no-store

https://github.com/cloudflare/workerd/issues/698#issuecomment-2494460498