Skip to content

Commit

Permalink
Prevent regression of resetting fetch
Browse files Browse the repository at this point in the history
  • Loading branch information
unstubbable committed Aug 9, 2024
1 parent 5310886 commit 21717c9
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions test/development/app-dir/dev-fetch-hmr/app/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,16 @@ import { ReactNode } from 'react'
const magicNumber = Math.random()
const originalFetch = globalThis.fetch

globalThis.fetch = async (
if (originalFetch.name === 'monkeyPatchedFetch') {
throw new Error(
'Patching over already patched fetch. This creates a memory leak.'
)
}

globalThis.fetch = async function monkeyPatchedFetch(
resource: URL | RequestInfo,
options?: RequestInit
) => {
) {
const request = new Request(resource)

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

0 comments on commit 21717c9

Please sign in to comment.