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