@@ -17,7 +17,7 @@ import { nextResponseProxy } from '../revalidate.js'
1717import { setFetchBeforeNextPatchedIt } from '../storage/storage.cjs'
1818
1919import { getLogger , type RequestContext } from './request-context.cjs'
20- import { getTracer } from './tracer.cjs'
20+ import { getTracer , recordWarning } from './tracer.cjs'
2121import { setupWaitUntil } from './wait-until.cjs'
2222
2323setFetchBeforeNextPatchedIt ( globalThis . fetch )
@@ -117,11 +117,6 @@ export default async (
117117 const nextCache = response . headers . get ( 'x-nextjs-cache' )
118118 const isServedFromNextCache = nextCache === 'HIT' || nextCache === 'STALE'
119119
120- topLevelSpan . setAttributes ( {
121- 'x-nextjs-cache' : nextCache ?? undefined ,
122- isServedFromNextCache,
123- } )
124-
125120 if ( isServedFromNextCache ) {
126121 await adjustDateHeader ( {
127122 headers : response . headers ,
@@ -136,6 +131,41 @@ export default async (
136131 setVaryHeaders ( response . headers , request , nextConfig )
137132 setCacheStatusHeader ( response . headers , nextCache )
138133
134+ const netlifyVary = response . headers . get ( 'netlify-vary' ) ?? undefined
135+ const netlifyCdnCacheControl = response . headers . get ( 'netlify-cdn-cache-control' ) ?? undefined
136+ topLevelSpan . setAttributes ( {
137+ 'x-nextjs-cache' : nextCache ?? undefined ,
138+ isServedFromNextCache,
139+ netlifyVary,
140+ netlifyCdnCacheControl,
141+ } )
142+
143+ if ( requestContext . isCacheableAppPage ) {
144+ const isRSCRequest = request . headers . get ( 'rsc' ) === '1'
145+ const contentType = response . headers . get ( 'content-type' ) ?? undefined
146+
147+ const isExpectedContentType =
148+ ( ( isRSCRequest && contentType ?. includes ( 'text/x-component' ) ) ||
149+ ( ! isRSCRequest && contentType ?. includes ( 'text/html' ) ) ) ??
150+ false
151+
152+ topLevelSpan . setAttributes ( {
153+ isRSCRequest,
154+ isCacheableAppPage : true ,
155+ contentType,
156+ isExpectedContentType,
157+ } )
158+
159+ if ( ! isExpectedContentType ) {
160+ recordWarning (
161+ new Error (
162+ `Unexpected content type was produced for App Router page response (isRSCRequest: ${ isRSCRequest } , contentType: ${ contentType } )` ,
163+ ) ,
164+ topLevelSpan ,
165+ )
166+ }
167+ }
168+
139169 async function waitForBackgroundWork ( ) {
140170 // it's important to keep the stream open until the next handler has finished
141171 await nextHandlerPromise
0 commit comments