Skip to content

Commit 77e31d5

Browse files
update the patchExceptionBubbling patch (#232)
* update the `patchExceptionBubbling` patch --------- Co-authored-by: Victor Berchet <[email protected]>
1 parent 8e4013f commit 77e31d5

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

.changeset/cold-plants-deliver.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@opennextjs/cloudflare": patch
3+
---
4+
5+
update the `patchExceptionBubbling` patch

packages/cloudflare/src/cli/build/patches/to-investigate/patch-exception-bubbling.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,14 @@
55
* promises.
66
*/
77
export function patchExceptionBubbling(code: string) {
8-
return code.replace('_nextBubbleNoFallback = "1"', "_nextBubbleNoFallback = undefined");
8+
// The code before had: `query._nextBubbleNoFallback = '1'`, that has ben refactored to
9+
// `addRequestMeta(req, 'bubbleNoFallback', true)` in https://github.com/vercel/next.js/pull/74100
10+
// we need to support both for backward compatibility, that's why we have the following if statement
11+
if (code.includes("_nextBubbleNoFallback")) {
12+
return code.replace('_nextBubbleNoFallback = "1"', "_nextBubbleNoFallback = undefined");
13+
}
14+
15+
// The Next.js transpiled code contains something like `(0, _requestmeta.addRequestMeta)(req, "bubbleNoFallback", true);`
16+
// and we want to update it to `(0, _requestmeta.addRequestMeta)(req, "bubbleNoFallback", false);`
17+
return code.replace(/\((.*?.addRequestMeta\)\(.*?,\s+"bubbleNoFallback"),\s+true\)/, "($1, false)");
918
}

0 commit comments

Comments
 (0)