Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove the cache property from calls to new Request(...) in React #771

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

james-elicx
Copy link
Contributor

In the React server code, there is a ternary where they create a new Request object and forward all properties on RequestInit to it. This won't work in workerd due to the cache property being present. Therefore, we need to overwrite their ternary with a way for us to strip the cache property from the RequestInit object.

https://github.com/vercel/next.js/blob/9ec37c12/packages/next/src/compiled/react/cjs/react.react-server.production.js#L87

Additionally, once this patch has been added, it looks like the error can then happen in our patched fetch. Therefore, also adding similar logic there to strip out the cache property from the RequestInit object.

fixes #719

Copy link

changeset-bot bot commented May 4, 2024

🦋 Changeset detected

Latest commit: 1f5539f

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
@cloudflare/next-on-pages Patch
eslint-plugin-next-on-pages Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link
Contributor

github-actions bot commented May 4, 2024

🧪 Prereleases are available for testing 🧪

@cloudflare/next-on-pages

You can install this latest build in your project with:

npm install --save-dev https://prerelease-registry.devprod.cloudflare.dev/next-on-pages/runs/9067847845/npm-package-next-on-pages-771

@cloudflare/eslint-plugin-next-on-pages

You can install this latest build in your project with:

npm install --save-dev https://prerelease-registry.devprod.cloudflare.dev/next-on-pages/runs/9067847845/npm-package-eslint-plugin-next-on-pages-771

@dario-piotrowicz
Copy link
Member

dario-piotrowicz commented May 5, 2024

Thanks a lot for the PR @james-elicx 😄

But it seems like the e2es are failing, and the failures do seem legitimate:

Could you please have a look? 🙏

@james-elicx
Copy link
Contributor Author

argh, i was hoping a rerun might fix them. welp. that's irritating

@dario-piotrowicz
Copy link
Member

argh, i was hoping a rerun might fix them. welp. that's irritating

yeah no, I already did try rerunning them 🥲

Also usually they kind of either all run or all (or most) fail, when just a few tests fail like now I think that does indicate a real regression/issue 😅

@james-elicx james-elicx force-pushed the james/fix-cache-request-init branch 2 times, most recently from 2e5bcb1 to d81eaff Compare May 13, 2024 17:15
@james-elicx james-elicx force-pushed the james/fix-cache-request-init branch from d81eaff to 63cb2fe Compare May 13, 2024 17:28
@james-elicx james-elicx force-pushed the james/fix-cache-request-init branch from e6faca1 to 1f5539f Compare May 13, 2024 18:18
@james-elicx james-elicx marked this pull request as draft May 14, 2024 22:25
@ehabsakran
Copy link

What's the status of this PR? I'm having this issue with Cloudflare pages and next-firebase-auth-edge library.

@james-elicx james-elicx marked this pull request as ready for review May 27, 2024 11:07
@james-elicx
Copy link
Contributor Author

What's the status of this PR? I'm having this issue with Cloudflare pages and next-firebase-auth-edge library.

i think it's probably fine to merge personally.

the area of caution is we haven't done any tests about if this would cause a regression for how the fetch cache in nextjs works. i feel like it would probably be okay though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[🐛 Bug]: The 'cache' field on 'RequestInitializerDict' is not implemented.
3 participants