Skip to content

Commit 99f28d7

Browse files
authored
drop the AbortController patch (#519)
1 parent aef8e51 commit 99f28d7

File tree

1 file changed

+11
-21
lines changed

1 file changed

+11
-21
lines changed

packages/cloudflare/src/cli/build/patches/plugins/next-minimal.ts

Lines changed: 11 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,17 @@
11
import { patchCode } from "@opennextjs/aws/build/patch/astCodePatcher.js";
22
import { ContentUpdater, type Plugin } from "@opennextjs/aws/plugins/content-updater.js";
33

4+
// Remove an instantiation of `AbortController` from the runtime.
5+
//
6+
// Solves https://github.com/cloudflare/workerd/issues/3657:
7+
// - The `AbortController` is meant for the client side, but ends in the server code somehow.
8+
// That's why we can get ride of it. See https://github.com/vercel/next.js/pull/73975/files.
9+
// - Top level instantiation of `AbortController` are not supported by workerd as of March, 2025.
10+
// See https://github.com/cloudflare/workerd/issues/3657
11+
// - As Next code is not more executed at top level, we do not need to apply this patch
12+
// See https://github.com/opennextjs/opennextjs-cloudflare/pull/497
13+
//
414
// We try to be as specific as possible to avoid patching the wrong thing here
5-
// It seems that there is a bug in the worker runtime. When the AbortController is created outside of the request context it throws an error (not sure if it's expected or not) except in this case. https://github.com/cloudflare/workerd/issues/3657
6-
// It fails while requiring the `app-page.runtime.prod.js` file, but instead of throwing an error, it just return an empty object for the `require('app-page.runtime.prod.js')` call which makes every request to an app router page fail.
7-
// If it's a bug in workerd and it's not expected to throw an error, we can remove this patch.
815
export const abortControllerRule = `
916
rule:
1017
all:
@@ -69,19 +76,7 @@ fix:
6976
`;
7077

7178
export function patchNextMinimal(updater: ContentUpdater): Plugin {
72-
updater.updateContent("patch-abortController-next15.2", [
73-
{
74-
field: {
75-
filter: /app-page(-experimental)?\.runtime\.prod\.js$/,
76-
contentFilter: /new AbortController/,
77-
callback: ({ contents }) => {
78-
return patchCode(contents, abortControllerRule);
79-
},
80-
},
81-
},
82-
]);
83-
84-
updater.updateContent("patch-next-minimal", [
79+
return updater.updateContent("patch-next-minimal", [
8580
{
8681
field: {
8782
filter: /next-server\.(js)$/,
@@ -92,9 +87,4 @@ export function patchNextMinimal(updater: ContentUpdater): Plugin {
9287
},
9388
},
9489
]);
95-
96-
return {
97-
name: "patch-abortController",
98-
setup() {},
99-
};
10090
}

0 commit comments

Comments
 (0)