Skip to content

Commit e8801c2

Browse files
committed
drop the AbortController patch
1 parent fafadaa commit e8801c2

File tree

2 files changed

+1
-130
lines changed

2 files changed

+1
-130
lines changed

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

Lines changed: 0 additions & 76 deletions
This file was deleted.
Lines changed: 1 addition & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,6 @@
11
import { patchCode } from "@opennextjs/aws/build/patch/astCodePatcher.js";
22
import { ContentUpdater, type Plugin } from "@opennextjs/aws/plugins/content-updater.js";
33

4-
// 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.
8-
export const abortControllerRule = `
9-
rule:
10-
all:
11-
- kind: lexical_declaration
12-
pattern: let $VAR = new AbortController
13-
- precedes:
14-
kind: function_declaration
15-
stopBy: end
16-
has:
17-
kind: statement_block
18-
has:
19-
kind: try_statement
20-
has:
21-
kind: catch_clause
22-
has:
23-
kind: statement_block
24-
has:
25-
kind: return_statement
26-
all:
27-
- has:
28-
stopBy: end
29-
kind: member_expression
30-
pattern: $VAR.signal.aborted
31-
- has:
32-
stopBy: end
33-
kind: call_expression
34-
regex: console.error\\("Failed to fetch RSC payload for
35-
36-
fix:
37-
'let $VAR = {signal:{aborted: false}};'
38-
`;
39-
404
// This rule is used instead of defining `process.env.NEXT_MINIMAL` in the `esbuild config.
415
// Do we want to entirely replace these functions to reduce the bundle size?
426
// In next `renderHTML` is used as a fallback in case of errors, but in minimal mode it just throws the error and the responsibility of handling it is on the infra.
@@ -69,19 +33,7 @@ fix:
6933
`;
7034

7135
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", [
36+
return updater.updateContent("patch-next-minimal", [
8537
{
8638
field: {
8739
filter: /next-server\.(js)$/,
@@ -92,9 +44,4 @@ export function patchNextMinimal(updater: ContentUpdater): Plugin {
9244
},
9345
},
9446
]);
95-
96-
return {
97-
name: "patch-abortController",
98-
setup() {},
99-
};
10047
}

0 commit comments

Comments
 (0)