Skip to content

Commit

Permalink
update the patchExceptionBubbling patch (#232)
Browse files Browse the repository at this point in the history
* update the `patchExceptionBubbling` patch

---------

Co-authored-by: Victor Berchet <[email protected]>
  • Loading branch information
dario-piotrowicz and vicb authored Jan 8, 2025
1 parent 8e4013f commit 77e31d5
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/cold-plants-deliver.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@opennextjs/cloudflare": patch
---

update the `patchExceptionBubbling` patch
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,14 @@
* promises.
*/
export function patchExceptionBubbling(code: string) {
return code.replace('_nextBubbleNoFallback = "1"', "_nextBubbleNoFallback = undefined");
// The code before had: `query._nextBubbleNoFallback = '1'`, that has ben refactored to
// `addRequestMeta(req, 'bubbleNoFallback', true)` in https://github.com/vercel/next.js/pull/74100
// we need to support both for backward compatibility, that's why we have the following if statement
if (code.includes("_nextBubbleNoFallback")) {
return code.replace('_nextBubbleNoFallback = "1"', "_nextBubbleNoFallback = undefined");
}

// The Next.js transpiled code contains something like `(0, _requestmeta.addRequestMeta)(req, "bubbleNoFallback", true);`
// and we want to update it to `(0, _requestmeta.addRequestMeta)(req, "bubbleNoFallback", false);`
return code.replace(/\((.*?.addRequestMeta\)\(.*?,\s+"bubbleNoFallback"),\s+true\)/, "($1, false)");
}

0 comments on commit 77e31d5

Please sign in to comment.