@@ -48,7 +48,6 @@ import {
4848 RSC_HEADER ,
4949 NEXT_ROUTER_PREFETCH_HEADER ,
5050 NEXT_ROUTER_SEGMENT_PREFETCH_HEADER ,
51- NEXT_INSTANT_PREFETCH_HEADER ,
5251 NEXT_INSTANT_TEST_COOKIE ,
5352 NEXT_IS_PRERENDER_HEADER ,
5453 NEXT_DID_POSTPONE_HEADER ,
@@ -420,17 +419,20 @@ export async function handler(
420419 // Enable the Instant Navigation Testing API. Renders only the prefetched
421420 // portion of the page, excluding dynamic content. This allows tests to
422421 // assert on the prefetched UI state deterministically.
423- // - Header: Used for client-side navigations where we can set request headers
424- // - Cookie: Used for MPA navigations (page reload, full page load) where we
425- // can't set request headers. Only applies to document requests (no RSC
426- // header) - RSC requests should proceed normally even during a locked scope,
427- // with blocking happening on the client side.
422+ //
423+ // The instant test cookie is sent automatically with all requests while a
424+ // navigation lock is held. We treat a request as a test render when the
425+ // cookie is present and either:
426+ // - it's a document request (no RSC header) — covers MPA navigations
427+ // - it's a prefetch RSC request — covers client-side prefetches
428+ // Regular RSC navigation requests proceed normally even during a locked
429+ // scope; blocking happens on the client side.
428430 const isInstantNavigationTest =
429431 exposeTestingApi &&
430- ( req . headers [ NEXT_INSTANT_PREFETCH_HEADER ] === '1' ||
431- ( ! isRSCRequestHeader ( req . headers [ RSC_HEADER ] ) &&
432- typeof req . headers . cookie === 'string' &&
433- req . headers . cookie . includes ( NEXT_INSTANT_TEST_COOKIE + '=' ) ) )
432+ typeof req . headers . cookie === 'string' &&
433+ req . headers . cookie . includes ( NEXT_INSTANT_TEST_COOKIE + '=' ) &&
434+ ( ! isRSCRequestHeader ( req . headers [ RSC_HEADER ] ) ||
435+ req . headers [ NEXT_ROUTER_PREFETCH_HEADER ] === '1' )
434436
435437 // This page supports PPR if it is marked as being `PARTIALLY_STATIC` in the
436438 // prerender manifest and this is an app page.
0 commit comments