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 authored and lubieowoce committed Aug 12, 2024
1 parent c516f44 commit b2ba578
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 b2ba578

Please sign in to comment.