Skip to content

Commit 317e872

Browse files
authored
fix fetch patch hanging promise by moving symbol to globalThis (#770)
1 parent f150546 commit 317e872

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

.changeset/itchy-cheetahs-design.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@cloudflare/next-on-pages': patch
3+
---
4+
5+
Fix hanging promise caused by fetch patch symbol

packages/next-on-pages/templates/_worker.js/utils/fetch.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@ import { handleSuspenseCacheRequest } from './cache';
55
* to work
66
*/
77
export function patchFetch(): void {
8-
const alreadyPatched = (globalThis.fetch as Fetch)[patchFlagSymbol];
8+
const alreadyPatched = (globalThis as GlobalWithPatchSymbol)[patchFlagSymbol];
99

1010
if (alreadyPatched) return;
1111

1212
applyPatch();
1313

14-
(globalThis.fetch as Fetch)[patchFlagSymbol] = true;
14+
(globalThis as GlobalWithPatchSymbol)[patchFlagSymbol] = true;
1515
}
1616

1717
function applyPatch() {
@@ -117,4 +117,4 @@ function setRequestUserAgentIfNeeded(
117117

118118
const patchFlagSymbol = Symbol.for('next-on-pages fetch patch');
119119

120-
type Fetch = typeof globalThis.fetch & { [patchFlagSymbol]: boolean };
120+
type GlobalWithPatchSymbol = typeof globalThis & { [patchFlagSymbol]: boolean };

0 commit comments

Comments
 (0)