Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions .changeset/few-ducks-listen.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
"@opennextjs/cloudflare": patch
---

fix: make sure that fetch cache `set`s are properly awaited

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`
2 changes: 1 addition & 1 deletion examples/e2e/app-router/e2e/ssr.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ test.skip("Server Side Render and loading.tsx", async ({ page }) => {
}
});

test.skip("Fetch cache properly cached", async ({ page }) => {
test("Fetch cache properly cached", async ({ page }) => {
await page.goto("/ssr");
const originalDate = await page.getByText("Cached fetch:").textContent();
await page.waitForTimeout(2000);
Expand Down
2 changes: 2 additions & 0 deletions packages/cloudflare/src/cli/build/bundle-server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { patchVercelOgLibrary } from "./patches/ast/patch-vercel-og-library.js";
import { patchWebpackRuntime } from "./patches/ast/webpack-runtime.js";
import * as patches from "./patches/index.js";
import { ContentUpdater } from "./patches/plugins/content-updater.js";
import { patchFetchCacheSetMissingWaitUntil } from "./patches/plugins/fetch-cache-wait-until.js";
import { patchLoadInstrumentation } from "./patches/plugins/load-instrumentation.js";
import { handleOptionalDependencies } from "./patches/plugins/optional-deps.js";
import { fixRequire } from "./patches/plugins/require.js";
Expand Down Expand Up @@ -87,6 +88,7 @@ export async function bundleServer(buildOpts: BuildOptions): Promise<void> {
fixRequire(updater),
handleOptionalDependencies(optionalDependencies),
patchLoadInstrumentation(updater),
patchFetchCacheSetMissingWaitUntil(updater),
// Apply updater updaters, must be the last plugin
updater.plugin,
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,10 @@ export class ContentUpdater {
if (namespace !== undefined && args.namespace !== namespace) {
continue;
}
if (!filter.test(args.path)) {
if (!args.path.match(filter)) {
continue;
}
if (!contentFilter.test(contents)) {
if (!contents.match(contentFilter)) {
continue;
}
contents = (await callback({ contents, path: args.path })) ?? contents;
Expand Down
Loading