diff --git a/.changeset/itchy-cheetahs-design.md b/.changeset/itchy-cheetahs-design.md new file mode 100644 index 000000000..818a68714 --- /dev/null +++ b/.changeset/itchy-cheetahs-design.md @@ -0,0 +1,5 @@ +--- +'@cloudflare/next-on-pages': patch +--- + +Fix hanging promise caused by fetch patch symbol diff --git a/packages/next-on-pages/templates/_worker.js/utils/fetch.ts b/packages/next-on-pages/templates/_worker.js/utils/fetch.ts index da353ceb7..2784189fd 100644 --- a/packages/next-on-pages/templates/_worker.js/utils/fetch.ts +++ b/packages/next-on-pages/templates/_worker.js/utils/fetch.ts @@ -5,13 +5,13 @@ import { handleSuspenseCacheRequest } from './cache'; * to work */ export function patchFetch(): void { - const alreadyPatched = (globalThis.fetch as Fetch)[patchFlagSymbol]; + const alreadyPatched = (globalThis as GlobalWithPatchSymbol)[patchFlagSymbol]; if (alreadyPatched) return; applyPatch(); - (globalThis.fetch as Fetch)[patchFlagSymbol] = true; + (globalThis as GlobalWithPatchSymbol)[patchFlagSymbol] = true; } function applyPatch() { @@ -117,4 +117,4 @@ function setRequestUserAgentIfNeeded( const patchFlagSymbol = Symbol.for('next-on-pages fetch patch'); -type Fetch = typeof globalThis.fetch & { [patchFlagSymbol]: boolean }; +type GlobalWithPatchSymbol = typeof globalThis & { [patchFlagSymbol]: boolean };