Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/next/src/server/lib/incremental-cache/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,7 @@ export class IncrementalCache implements IncrementalCacheType {
const headers =
typeof (init.headers || {}).keys === 'function'
? Object.fromEntries(init.headers as Headers)
: Object.assign(init.headers || {}, {})
: Object.assign({}, init.headers)

if ('traceparent' in headers) delete headers['traceparent']

Expand Down
36 changes: 36 additions & 0 deletions test/e2e/app-dir/app-static/app-static.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,22 @@ createNextDescribe(
}
})

it('should still cache even though the `traceparent` header was different', async () => {
const res = await next.fetch('/strip-header-traceparent')
expect(res.status).toBe(200)

const html = await res.text()
const $ = cheerio.load(html)

const data1 = $('#data1').text()
const data2 = $('#data2').text()
expect(data1).toBeTruthy()
expect(data1).toBe(data2)

const echoedHeaders = JSON.parse($('#echoedHeaders').text())
expect(echoedHeaders.headers.traceparent).toEqual('C')
})

it('should warn for too many cache tags', async () => {
const res = await next.fetch('/too-many-cache-tags')
expect(res.status).toBe(200)
Expand Down Expand Up @@ -822,6 +838,10 @@ createNextDescribe(
"static-to-dynamic-error-forced/[id]/page_client-reference-manifest.js",
"static-to-dynamic-error/[id]/page.js",
"static-to-dynamic-error/[id]/page_client-reference-manifest.js",
"strip-header-traceparent.html",
"strip-header-traceparent.rsc",
"strip-header-traceparent/page.js",
"strip-header-traceparent/page_client-reference-manifest.js",
"too-many-cache-tags/page.js",
"too-many-cache-tags/page_client-reference-manifest.js",
"unstable-cache/dynamic-undefined/page.js",
Expand Down Expand Up @@ -1544,6 +1564,22 @@ createNextDescribe(
"initialRevalidateSeconds": false,
"srcRoute": "/ssg-draft-mode/[[...route]]",
},
"/strip-header-traceparent": {
"dataRoute": "/strip-header-traceparent.rsc",
"experimentalBypassFor": [
{
"key": "Next-Action",
"type": "header",
},
{
"key": "content-type",
"type": "header",
"value": "multipart/form-data;.*",
},
],
"initialRevalidateSeconds": 50,
"srcRoute": "/strip-header-traceparent",
},
"/variable-config-revalidate/revalidate-3": {
"dataRoute": "/variable-config-revalidate/revalidate-3.rsc",
"experimentalBypassFor": [
Expand Down
33 changes: 33 additions & 0 deletions test/e2e/app-dir/app-static/app/strip-header-traceparent/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
export default async function Page() {
const data1 = await fetch(
'https://next-data-api-endpoint.vercel.app/api/random',
{
headers: { traceparent: 'A' },
next: { revalidate: 50 },
}
).then((res) => res.text())

const data2 = await fetch(
'https://next-data-api-endpoint.vercel.app/api/random',
{
headers: { traceparent: 'B' },
next: { revalidate: 50 },
}
).then((res) => res.text())

const echoedHeaders = await fetch(
'https://next-data-api-endpoint.vercel.app/api/echo-headers',
{
headers: { traceparent: 'C' },
next: { revalidate: 50 },
}
).then((res) => res.text())

return (
<>
<p id="data1">{data1}</p>
<p id="data2">{data2}</p>
<p id="echoedHeaders">{echoedHeaders}</p>
</>
)
}