Skip to content

Commit b2ba578

Browse files
unstubbablelubieowoce
authored andcommitted
Prevent regression of resetting fetch
1 parent c516f44 commit b2ba578

File tree

1 file changed

+8
-2
lines changed
  • test/development/app-dir/dev-fetch-hmr/app

1 file changed

+8
-2
lines changed

test/development/app-dir/dev-fetch-hmr/app/layout.tsx

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,16 @@ import { ReactNode } from 'react'
44
const magicNumber = Math.random()
55
const originalFetch = globalThis.fetch
66

7-
globalThis.fetch = async (
7+
if (originalFetch.name === 'monkeyPatchedFetch') {
8+
throw new Error(
9+
'Patching over already patched fetch. This creates a memory leak.'
10+
)
11+
}
12+
13+
globalThis.fetch = async function monkeyPatchedFetch(
814
resource: URL | RequestInfo,
915
options?: RequestInit
10-
) => {
16+
) {
1117
const request = new Request(resource)
1218

1319
if (request.url === 'http://fake.url/secret') {

0 commit comments

Comments
 (0)