File tree Expand file tree Collapse file tree 2 files changed +43
-0
lines changed
packages/open-next/src/build Expand file tree Collapse file tree 2 files changed +43
-0
lines changed Original file line number Diff line number Diff line change @@ -17,6 +17,7 @@ import { generateEdgeBundle } from "./edge/createEdgeBundle.js";
17
17
import * as buildHelper from "./helper.js" ;
18
18
import { installDependencies } from "./installDeps.js" ;
19
19
import { type CodePatcher , applyCodePatches } from "./patch/codePatcher.js" ;
20
+ import { patchFetchCacheSetMissingWaitUntil } from "./patch/patchFetchCacheWaitUntil.js" ;
20
21
21
22
interface CodeCustomization {
22
23
// These patches are meant to apply on user and next generated code
Original file line number Diff line number Diff line change
1
+ import { getCrossPlatformPathRegex } from "utils/regex.js" ;
2
+ import { createPatchCode } from "./astCodePatcher.js" ;
3
+ import type { CodePatcher } from "./codePatcher" ;
4
+
5
+ export const rule = `
6
+ rule:
7
+ kind: call_expression
8
+ pattern: $PROMISE
9
+ all:
10
+ - has: { pattern: $_.arrayBuffer().then, stopBy: end }
11
+ - has: { pattern: "Buffer.from", stopBy: end }
12
+ - any:
13
+ - inside:
14
+ kind: sequence_expression
15
+ inside:
16
+ kind: return_statement
17
+ - inside:
18
+ kind: expression_statement
19
+ precedes:
20
+ kind: return_statement
21
+ - has: { pattern: $_.FETCH, stopBy: end }
22
+
23
+ fix: |
24
+ globalThis.__openNextAls?.getStore()?.pendingPromiseRunner.add($PROMISE)
25
+ ` ;
26
+
27
+ export const patchFetchCacheSetMissingWaitUntil : CodePatcher = {
28
+ name : "patch-fetch-cache-set-missing-wait-until" ,
29
+ patches : [
30
+ {
31
+ versions : ">=15.0.0" ,
32
+ field : {
33
+ pathFilter : getCrossPlatformPathRegex (
34
+ String . raw `(server/chunks/.*\.js|.*\.runtime\..*\.js|patch-fetch\.js)$` ,
35
+ { escape : false } ,
36
+ ) ,
37
+ contentFilter : / a r r a y B u f f e r \( \) \s * \. t h e n / ,
38
+ patchCode : createPatchCode ( rule ) ,
39
+ } ,
40
+ } ,
41
+ ] ,
42
+ } ;
You can’t perform that action at this time.
0 commit comments