Skip to content

Commit 68f8e79

Browse files
authored
fix: separate response cache if debug logging header is used (#384)
* fix: separate response cache if debug logging header is used * test: update 'new' assertions
1 parent 7528ee2 commit 68f8e79

File tree

4 files changed

+11
-15
lines changed

4 files changed

+11
-15
lines changed

src/build/templates/handler-monorepo.tmpl.js

+1-3
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,7 @@ export default async function (req, context) {
1616
tracing.start()
1717
}
1818

19-
const requestContext = createRequestContext(
20-
req.headers.get('x-nf-debug-logging') || req.headers.get('x-next-debug-logging'),
21-
)
19+
const requestContext = createRequestContext(req.headers.get('x-next-debug-logging'))
2220
const tracer = getTracer()
2321

2422
const handlerResponse = await runWithRequestContext(requestContext, () => {

src/build/templates/handler.tmpl.js

+1-3
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,7 @@ export default async function handler(req, context) {
1313
if (process.env.NETLIFY_OTLP_TRACE_EXPORTER_URL) {
1414
tracing.start()
1515
}
16-
const requestContext = createRequestContext(
17-
req.headers.get('x-nf-debug-logging') || req.headers.get('x-next-debug-logging'),
18-
)
16+
const requestContext = createRequestContext(req.headers.get('x-next-debug-logging'))
1917
const tracer = getTracer()
2018

2119
const handlerResponse = await runWithRequestContext(requestContext, () => {

src/run/headers.test.ts

+8-8
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ describe('headers', () => {
4040

4141
expect(headers.set).toBeCalledWith(
4242
'netlify-vary',
43-
'header=x-nextjs-data,cookie=__prerender_bypass|__next_preview_data',
43+
'header=x-nextjs-data|x-next-debug-logging,cookie=__prerender_bypass|__next_preview_data',
4444
)
4545
})
4646

@@ -56,7 +56,7 @@ describe('headers', () => {
5656

5757
expect(headers.set).toBeCalledWith(
5858
'netlify-vary',
59-
'header=x-nextjs-data|Accept|Accept-Language,cookie=__prerender_bypass|__next_preview_data',
59+
'header=x-nextjs-data|x-next-debug-logging|Accept|Accept-Language,cookie=__prerender_bypass|__next_preview_data',
6060
)
6161
})
6262

@@ -77,7 +77,7 @@ describe('headers', () => {
7777

7878
expect(headers.set).toBeCalledWith(
7979
'netlify-vary',
80-
'header=x-nextjs-data,cookie=__prerender_bypass|__next_preview_data',
80+
'header=x-nextjs-data|x-next-debug-logging,cookie=__prerender_bypass|__next_preview_data',
8181
)
8282
})
8383

@@ -97,7 +97,7 @@ describe('headers', () => {
9797

9898
expect(headers.set).toBeCalledWith(
9999
'netlify-vary',
100-
'header=x-nextjs-data,cookie=__prerender_bypass|__next_preview_data',
100+
'header=x-nextjs-data|x-next-debug-logging,cookie=__prerender_bypass|__next_preview_data',
101101
)
102102
})
103103

@@ -117,7 +117,7 @@ describe('headers', () => {
117117

118118
expect(headers.set).toBeCalledWith(
119119
'netlify-vary',
120-
'header=x-nextjs-data,language=en|de|fr,cookie=__prerender_bypass|__next_preview_data|NEXT_LOCALE',
120+
'header=x-nextjs-data|x-next-debug-logging,language=en|de|fr,cookie=__prerender_bypass|__next_preview_data|NEXT_LOCALE',
121121
)
122122
})
123123

@@ -138,7 +138,7 @@ describe('headers', () => {
138138

139139
expect(headers.set).toBeCalledWith(
140140
'netlify-vary',
141-
'header=x-nextjs-data,language=en|de|fr,cookie=__prerender_bypass|__next_preview_data|NEXT_LOCALE',
141+
'header=x-nextjs-data|x-next-debug-logging,language=en|de|fr,cookie=__prerender_bypass|__next_preview_data|NEXT_LOCALE',
142142
)
143143
})
144144

@@ -161,7 +161,7 @@ describe('headers', () => {
161161

162162
expect(headers.set).toBeCalledWith(
163163
'netlify-vary',
164-
'query,header=x-nextjs-data|x-custom-header,language=en|de|fr|es,cookie=__prerender_bypass|__next_preview_data|NEXT_LOCALE|ab_test,country=es',
164+
'query,header=x-nextjs-data|x-next-debug-logging|x-custom-header,language=en|de|fr|es,cookie=__prerender_bypass|__next_preview_data|NEXT_LOCALE|ab_test,country=es',
165165
)
166166
})
167167

@@ -185,7 +185,7 @@ describe('headers', () => {
185185

186186
expect(headers.set).toBeCalledWith(
187187
'netlify-vary',
188-
'query=item_id|page|per_page,header=x-nextjs-data|x-custom-header,language=en|de|fr|es,cookie=__prerender_bypass|__next_preview_data|NEXT_LOCALE|ab_test,country=es',
188+
'query=item_id|page|per_page,header=x-nextjs-data|x-next-debug-logging|x-custom-header,language=en|de|fr|es,cookie=__prerender_bypass|__next_preview_data|NEXT_LOCALE|ab_test,country=es',
189189
)
190190
})
191191
})

src/run/headers.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ export const setVaryHeaders = (
8282
{ basePath, i18n }: Pick<NextConfigComplete, 'basePath' | 'i18n'>,
8383
) => {
8484
const netlifyVaryValues: NetlifyVaryValues = {
85-
header: ['x-nextjs-data'],
85+
header: ['x-nextjs-data', 'x-next-debug-logging'],
8686
language: [],
8787
cookie: ['__prerender_bypass', '__next_preview_data'],
8888
query: [],

0 commit comments

Comments
 (0)