-
Notifications
You must be signed in to change notification settings - Fork 26
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
fix: make sure that fetch cache sets are properly awaited #364
Conversation
🦋 Changeset detectedLatest commit: 107b285 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: |
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.
Added some comments.
Testing unminified is the most important
packages/cloudflare/src/cli/build/patches/plugins/fetch-cache-wait-until.spec.ts
Show resolved
Hide resolved
packages/cloudflare/src/cli/build/patches/plugins/fetch-cache-wait-until.ts
Outdated
Show resolved
Hide resolved
packages/cloudflare/src/cli/build/patches/plugins/fetch-cache-wait-until.ts
Show resolved
Hide resolved
packages/cloudflare/src/cli/build/patches/plugins/fetch-cache-wait-until.ts
Outdated
Show resolved
Hide resolved
packages/cloudflare/src/cli/build/patches/plugins/fetch-cache-wait-until.ts
Outdated
Show resolved
Hide resolved
packages/cloudflare/src/cli/build/patches/plugins/fetch-cache-wait-until.ts
Show resolved
Hide resolved
packages/cloudflare/src/cli/build/patches/plugins/fetch-cache-wait-until.ts
Outdated
Show resolved
Hide resolved
c0c83b9
to
3f7381b
Compare
packages/cloudflare/src/cli/build/patches/plugins/content-updater.ts
Outdated
Show resolved
Hide resolved
packages/cloudflare/src/cli/build/patches/plugins/fetch-cache-wait-until.ts
Outdated
Show resolved
Hide resolved
packages/cloudflare/src/cli/build/patches/plugins/fetch-cache-wait-until.ts
Outdated
Show resolved
Hide resolved
packages/cloudflare/src/cli/build/patches/plugins/fetch-cache-wait-until.spec.ts
Show resolved
Hide resolved
packages/cloudflare/src/cli/build/patches/plugins/fetch-cache-wait-until.ts
Outdated
Show resolved
Hide resolved
packages/cloudflare/src/cli/build/patches/plugins/fetch-cache-wait-until.ts
Outdated
Show resolved
Hide resolved
Next.js does not await promises that update the incremental cache for fetch requests, that is needed in our runtime otherwise the cache updates get lost, so this change makes sure that the promise is properly awaited via `waitUntil` Co-authored-by: Victor Berchet <[email protected]>
0826365
to
61484b6
Compare
packages/cloudflare/src/cli/build/patches/plugins/fetch-cache-wait-until.ts
Outdated
Show resolved
Hide resolved
packages/cloudflare/src/cli/build/patches/plugins/fetch-cache-wait-until.ts
Outdated
Show resolved
Hide resolved
packages/cloudflare/src/cli/build/patches/plugins/fetch-cache-wait-until.ts
Outdated
Show resolved
Hide resolved
@dario-piotrowicz maybe you try something like: rule:
kind: expression_statement
all:
- has: { pattern: "$$$_.then($$$_)", stopBy: end }
- has: { pattern: "Buffer.from", stopBy: end }
- has: { pattern: "$_.toString('base64')", stopBy: end }
- has: { pattern: "$_.CachedRouteKind.FETCH", stopBy: end } I have only tried on minified code but it should be possible to figure out something that works everywhere |
packages/cloudflare/src/cli/build/patches/plugins/fetch-cache-wait-until.ts
Outdated
Show resolved
Hide resolved
packages/cloudflare/src/cli/build/patches/plugins/fetch-cache-wait-until.ts
Outdated
Show resolved
Hide resolved
rule:
kind: expression_statement
all:
- has: { pattern: "$$$.then($$$)", stopBy: end }
- has: { pattern: "Buffer.from", stopBy: end }
- has: { pattern: "$_.toString('base64')", stopBy: end }
- any:
- has: { pattern: "CachedRouteKind.FETCH", stopBy: end }
- has: { pattern: "$_.CachedRouteKind.FETCH", stopBy: end }
- has: { pattern: "$$$.finally($$$)", stopBy: end } |
this doesn't work, if you want you can check that in the playground I've been using, here's the link to it: https://pastebin.mozilla.org/eEiLmsaF with my rule there are three matches, with yours 4 incorrect ones (I've also tried your rule in the adapter and it didn't result in a valid patch) |
packages/cloudflare/src/cli/build/patches/plugins/fetch-cache-wait-until.ts
Outdated
Show resolved
Hide resolved
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.
Nice work!
I added a comment inline, but LGTM 🚀
…wait-until.ts Co-authored-by: Victor Berchet <[email protected]>
One last thing before merging! The usage of |
@dario-piotrowicz There might be an issue with |
Looking at ![]() |
This reverts commit 5e97964.
No I've been debugging it and I'm pretty sure it has to do with the But ideally I think we should add an option to |
https://github.com/opennextjs/opennextjs-aws/blob/b59027a5899d25dd5263d1a272b33ec23fb683d3/packages/open-next/src/utils/regex.ts#L20 |
Maybe we should switch to I asked on the PR if we really need to |
oops, I missed that the flags were already configurable! 😅👍 |
good call! let's go with that 😄 |
@vicb, @conico974 the PR is ready to merge please let me know if we're all happy with it 🙂 |
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.
LGTM
Nice work on this one
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.
Awesome, thanks for your work on this PR 🎉
Next.js does not await promises that update the incremental cache for fetch requests,
that is needed in our runtime otherwise the cache updates get lost, so this change
makes sure that the promise is properly awaited via
waitUntil
resolves #328