Skip to content

Commit

Permalink
patch exception bubbling
Browse files Browse the repository at this point in the history
  • Loading branch information
james-elicx committed Oct 6, 2024
1 parent 78946b2 commit c8e492e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
2 changes: 2 additions & 0 deletions packages/cloudflare/src/cli/build/build-worker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { inlineEvalManifest } from "./patches/to-investigate/inline-eval-manifes
import { inlineMiddlewareManifestRequire } from "./patches/to-investigate/inline-middleware-manifest-require";
import { inlineNextRequire } from "./patches/to-investigate/inline-next-require";
import { patchCache } from "./patches/investigated/patch-cache";
import { patchExceptionBubbling } from "./patches/to-investigate/patch-exception-bubbling";
import { patchFindDir } from "./patches/to-investigate/patch-find-dir";
import { patchReadFile } from "./patches/to-investigate/patch-read-file";
import { patchRequire } from "./patches/investigated/patch-require";
Expand Down Expand Up @@ -164,6 +165,7 @@ async function updateWorkerBundledCode(workerOutputFile: string, config: Config)
patchedCode = inlineEvalManifest(patchedCode, config);
patchedCode = patchCache(patchedCode, config);
patchedCode = inlineMiddlewareManifestRequire(patchedCode, config);
patchedCode = patchExceptionBubbling(patchedCode);

await writeFile(workerOutputFile, patchedCode);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/**
* When using SSG and `dynamicParams = false`, Next.js throws a NoFallbackError. This error is
* bubbled up by default in Node.js servers, however this causes issues in the workerd with
* the current response handling and streaming implementation we have, and leads to hanging
* promises.
*/
export function patchExceptionBubbling(code: string) {
console.log("# patchExceptionBubbling");

return code.replace(/_nextBubbleNoFallback = "1"/, "_nextBubbleNoFallback = undefined");
}

0 comments on commit c8e492e

Please sign in to comment.