stytch-node icon indicating copy to clipboard operation
stytch-node copied to clipboard

How to disable `cache: "no-store"` after 9.0.5 update

Open tdwells90 opened this issue 1 year ago • 4 comments

Hi,

In Cloudflare Workers I'm receiving the error: The 'cache' field on 'RequestInitializerDict' is not implemented. This is due to the latest 9.0.5 update. 9.0.4 works fine.

Is there a way to remove this for 9.0.5 and any future updates?

Thanks, Tom.

tdwells90 avatar Oct 18 '23 23:10 tdwells90

Hey @tdwells90 for immediate resolution can you try using the workaround described in https://github.com/stytchauth/stytch-node/issues/262#issuecomment-1764910451 to manually edit the fetchConfig?

something like

function monkeyPatchStytchClientSettings(client: ...) {
  /* eslint-disable */
  const cl = <any>client;
  /* eslint-enable */
  cl.fetchConfig.cache = undefined;
}

should hopefully do the trick since the explicit undefined should override the key.

> { foo: 1, ...{foo: undefined}}
{ foo: undefined }

We'll see if we can detect the CF worker runtime and avoid setting that key as an immediate fix.

Would also be great for us to add automated tests that deploy to Cloudflare and verify that we don't break things. Right now that process is manual and we're not running it on every commit.

max-stytch avatar Oct 19 '23 17:10 max-stytch

@tdwells90 is this solution- https://github.com/cloudflare/workerd/issues/698#issuecomment-1737605504 - a viable workaround? It looks like cloudflare themselves plan on fixing this issue in some near future 🤞

max-stytch avatar Oct 19 '23 17:10 max-stytch

Going into /node_modules/stytch/dist/shared/index.js and commenting out the line that says cache: "no-store" (currently line 19) worked for me

kyleplo avatar Nov 15 '23 02:11 kyleplo

any updates on this?

cmnstmntmn avatar Nov 27 '23 09:11 cmnstmntmn