-
Notifications
You must be signed in to change notification settings - Fork 73
Fix fetch inside use cache
in ISR
#666
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
Conversation
🦋 Changeset detectedLatest commit: f4a744a The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
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 |
commit: |
Thanks for the PR nico 🙏 I'll review tomorrow. Do you understand why we "perform I/O on behalf of a different request"? |
I think i do, basically a function using It might be possible to fix it at the workerd level so that ALS |
* This is necessary because the createSnapshot function is causing I/O issues for | ||
* ISR/SSG revalidation in Cloudflare Workers. | ||
* TODO: Find a better fix for this issue. | ||
*/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you please add more details from the PR discussion:
This is because by default it will use AsyncLocalStorage.snapshot() and it will bind everything to the initial request context. The downsides is that use cache function will have access to the full request ALS context from next (i.e. cookies, headers ...)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the fix!
Using fetch (or I/O in general) inside of a
use cache
in an ISR/SSG route would make it crash with aCannot perform I/O on behalf of a different request
error during revalidation request if the instance is warm.This is because by default it will use
AsyncLocalStorage.snapshot()
and it will bind everything to the initial request context. The downsides is thatuse cache
function will have access to the full request ALS context from next (i.e. cookies, headers ...)