Skip to content

Commit c8e492e

Browse files
committed
patch exception bubbling
1 parent 78946b2 commit c8e492e

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

packages/cloudflare/src/cli/build/build-worker.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import { inlineEvalManifest } from "./patches/to-investigate/inline-eval-manifes
88
import { inlineMiddlewareManifestRequire } from "./patches/to-investigate/inline-middleware-manifest-require";
99
import { inlineNextRequire } from "./patches/to-investigate/inline-next-require";
1010
import { patchCache } from "./patches/investigated/patch-cache";
11+
import { patchExceptionBubbling } from "./patches/to-investigate/patch-exception-bubbling";
1112
import { patchFindDir } from "./patches/to-investigate/patch-find-dir";
1213
import { patchReadFile } from "./patches/to-investigate/patch-read-file";
1314
import { patchRequire } from "./patches/investigated/patch-require";
@@ -164,6 +165,7 @@ async function updateWorkerBundledCode(workerOutputFile: string, config: Config)
164165
patchedCode = inlineEvalManifest(patchedCode, config);
165166
patchedCode = patchCache(patchedCode, config);
166167
patchedCode = inlineMiddlewareManifestRequire(patchedCode, config);
168+
patchedCode = patchExceptionBubbling(patchedCode);
167169

168170
await writeFile(workerOutputFile, patchedCode);
169171
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
/**
2+
* When using SSG and `dynamicParams = false`, Next.js throws a NoFallbackError. This error is
3+
* bubbled up by default in Node.js servers, however this causes issues in the workerd with
4+
* the current response handling and streaming implementation we have, and leads to hanging
5+
* promises.
6+
*/
7+
export function patchExceptionBubbling(code: string) {
8+
console.log("# patchExceptionBubbling");
9+
10+
return code.replace(/_nextBubbleNoFallback = "1"/, "_nextBubbleNoFallback = undefined");
11+
}

0 commit comments

Comments
 (0)