Unverified Commit 4ac4b757 authored by JJ Kasper's avatar JJ Kasper Committed by GitHub
parent 6b276042
......@@ -822,7 +822,7 @@ jobs:
testDevLTS,
testProdLTS,
testDevE2ELTS,
testprode2elts,
testProdE2ELTS,
]
steps:
- run: exit 0
......
......@@ -14,10 +14,9 @@ export function patchFetch({
serverHooks: typeof import('../../client/components/hooks-server-context')
staticGenerationAsyncStorage: StaticGenerationAsyncStorage
}) {
if ((globalThis.fetch as any).patched) return
if ((fetch as any).__nextPatched) return
const { DynamicServerError } = serverHooks
const originFetch = fetch
// @ts-expect-error - we're patching fetch
......@@ -159,7 +158,8 @@ export function patchFetch({
revalidate > 0
) {
let base64Body = ''
const arrayBuffer = await res.arrayBuffer()
const resBlob = await res.blob()
const arrayBuffer = await resBlob.arrayBuffer()
if (process.env.NEXT_RUNTIME === 'edge') {
const { encode } =
......@@ -186,7 +186,8 @@ export function patchFetch({
} catch (err) {
console.warn(`Failed to set fetch cache`, input, err)
}
return new Response(arrayBuffer, {
return new Response(resBlob, {
headers: res.headers,
status: res.status,
})
......@@ -291,5 +292,5 @@ export function patchFetch({
return doOriginalFetch()
}
)
;(globalThis.fetch as any).patched = true
;(fetch as any).__nextPatched = true
}
......@@ -555,7 +555,6 @@ createNextDescribe(
expect($2('#data-body1').text()).toBe(dataBody1)
expect($2('#data-body2').text()).toBe(dataBody2)
expect($2('#data-body3').text()).toBe(dataBody3)
expect($2('#data-body4').text()).toBe(dataBody4)
return 'success'
}, 'success')
})
......
import { FormData, Blob } from 'next/dist/compiled/@edge-runtime/primitives'
const fetchRetry = async (url, init) => {
for (let i = 0; i < 5; i++) {
try {
......@@ -52,23 +50,7 @@ export default async function Page() {
}
).then((res) => res.text())
const formData = new FormData()
formData.append('hello', 'value')
formData.append('another', new Blob(['some text'], { type: 'text/plain' }))
formData.append('another', 'text')
const dataWithBody3 = await fetchRetry(
'https://next-data-api-endpoint.vercel.app/api/random',
{
method: 'POST',
body: formData,
next: {
revalidate: 10,
},
}
).then((res) => res.text())
const dataWithBody4 = await fetchRetry(
'https://next-data-api-endpoint.vercel.app/api/random',
{
method: 'POST',
......@@ -79,7 +61,7 @@ export default async function Page() {
}
).then((res) => res.text())
const dataWithBody5 = await fetchRetry(
const dataWithBody4 = await fetchRetry(
'https://next-data-api-endpoint.vercel.app/api/random',
{
method: 'POST',
......@@ -93,9 +75,8 @@ export default async function Page() {
<p id="page-data">{data}</p>
<p id="data-body1">{dataWithBody1}</p>
<p id="data-body2">{dataWithBody2}</p>
<p id="data-body3">{dataWithBody3}</p>
<p id="data-body4">{dataWithBody3}</p>
<p id="data-body4">{dataWithBody4}</p>
<p id="data-body5">{dataWithBody5}</p>
</>
)
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment