@@ -1028,7 +1028,6 @@ export async function fetchRouteOnCacheMiss(
1028
1028
1029
1029
writeDynamicTreeResponseIntoCache (
1030
1030
Date . now ( ) ,
1031
- task ,
1032
1031
response ,
1033
1032
serverData ,
1034
1033
entry ,
@@ -1247,10 +1246,6 @@ export async function fetchSegmentPrefetchesUsingDynamicRequest(
1247
1246
prefetchStream
1248
1247
) as Promise < NavigationFlightResponse > )
1249
1248
1250
- // Since we did not set the prefetch header, the response from the server
1251
- // will never contain dynamic holes.
1252
- const isResponsePartial = false
1253
-
1254
1249
// Aside from writing the data into the cache, this function also returns
1255
1250
// the entries that were fulfilled, so we can streamingly update their sizes
1256
1251
// in the LRU as more data comes in.
@@ -1259,7 +1254,6 @@ export async function fetchSegmentPrefetchesUsingDynamicRequest(
1259
1254
task ,
1260
1255
response ,
1261
1256
serverData ,
1262
- isResponsePartial ,
1263
1257
route ,
1264
1258
spawnedEntries
1265
1259
)
@@ -1275,7 +1269,6 @@ export async function fetchSegmentPrefetchesUsingDynamicRequest(
1275
1269
1276
1270
function writeDynamicTreeResponseIntoCache (
1277
1271
now : number ,
1278
- task : PrefetchTask ,
1279
1272
response : Response ,
1280
1273
serverData : NavigationFlightResponse ,
1281
1274
entry : PendingRouteCacheEntry ,
@@ -1318,43 +1311,16 @@ function writeDynamicTreeResponseIntoCache(
1318
1311
staleTimeHeaderSeconds !== null
1319
1312
? parseInt ( staleTimeHeaderSeconds , 10 ) * 1000
1320
1313
: STATIC_STALETIME_MS
1321
-
1322
- // If the response contains dynamic holes, then we must conservatively assume
1323
- // that any individual segment might contain dynamic holes, and also the
1324
- // head. If it did not contain dynamic holes, then we can assume every segment
1325
- // and the head is completely static.
1326
- const isResponsePartial =
1327
- response . headers . get ( NEXT_DID_POSTPONE_HEADER ) === '1'
1328
-
1329
- const fulfilledEntry = fulfillRouteCacheEntry (
1314
+ fulfillRouteCacheEntry (
1330
1315
entry ,
1331
1316
convertRootFlightRouterStateToRouteTree ( flightRouterState ) ,
1332
1317
flightData . head ,
1333
- isResponsePartial ,
1318
+ flightData . isHeadPartial ,
1334
1319
now + staleTimeMs ,
1335
1320
couldBeIntercepted ,
1336
1321
canonicalUrl ,
1337
1322
routeIsPPREnabled
1338
1323
)
1339
-
1340
- // If the server sent segment data as part of the response, we should write
1341
- // it into the cache to prevent a second, redundant prefetch request.
1342
- //
1343
- // TODO: When `clientSegmentCache` is enabled, the server does not include
1344
- // segment data when responding to a route tree prefetch request. However,
1345
- // when `clientSegmentCache` is set to "client-only", and PPR is enabled (or
1346
- // the page is fully static), the normal check is bypassed and the server
1347
- // responds with the full page. This is a temporary situation until we can
1348
- // remove the "client-only" option. Then, we can delete this function call.
1349
- writeDynamicRenderResponseIntoCache (
1350
- now ,
1351
- task ,
1352
- response ,
1353
- serverData ,
1354
- isResponsePartial ,
1355
- fulfilledEntry ,
1356
- null
1357
- )
1358
1324
}
1359
1325
1360
1326
function rejectSegmentEntriesIfStillPending (
@@ -1377,19 +1343,16 @@ function writeDynamicRenderResponseIntoCache(
1377
1343
task : PrefetchTask ,
1378
1344
response : Response ,
1379
1345
serverData : NavigationFlightResponse ,
1380
- isResponsePartial : boolean ,
1381
1346
route : FulfilledRouteCacheEntry ,
1382
- spawnedEntries : Map < string , PendingSegmentCacheEntry > | null
1347
+ spawnedEntries : Map < string , PendingSegmentCacheEntry >
1383
1348
) : Array < FulfilledSegmentCacheEntry > | null {
1384
1349
if ( serverData . b !== getAppBuildId ( ) ) {
1385
1350
// The server build does not match the client. Treat as a 404. During
1386
1351
// an actual navigation, the router will trigger an MPA navigation.
1387
1352
// TODO: Consider moving the build ID to a response header so we can check
1388
1353
// it before decoding the response, and so there's one way of checking
1389
1354
// across all response types.
1390
- if ( spawnedEntries !== null ) {
1391
- rejectSegmentEntriesIfStillPending ( spawnedEntries , now + 10 * 1000 )
1392
- }
1355
+ rejectSegmentEntriesIfStillPending ( spawnedEntries , now + 10 * 1000 )
1393
1356
return null
1394
1357
}
1395
1358
const flightDatas = normalizeFlightData ( serverData . f )
@@ -1432,7 +1395,6 @@ function writeDynamicRenderResponseIntoCache(
1432
1395
route ,
1433
1396
now + staleTimeMs ,
1434
1397
seedData ,
1435
- isResponsePartial ,
1436
1398
segmentKey ,
1437
1399
spawnedEntries
1438
1400
)
@@ -1446,14 +1408,11 @@ function writeDynamicRenderResponseIntoCache(
1446
1408
// segments we're marking as rejected here. We should mark on the segment
1447
1409
// somehow that the reason for the rejection is because of a non-PPR prefetch.
1448
1410
// That way a per-segment prefetch knows to disregard the rejection.
1449
- if ( spawnedEntries !== null ) {
1450
- const fulfilledEntries = rejectSegmentEntriesIfStillPending (
1451
- spawnedEntries ,
1452
- now + 10 * 1000
1453
- )
1454
- return fulfilledEntries
1455
- }
1456
- return null
1411
+ const fulfilledEntries = rejectSegmentEntriesIfStillPending (
1412
+ spawnedEntries ,
1413
+ now + 10 * 1000
1414
+ )
1415
+ return fulfilledEntries
1457
1416
}
1458
1417
1459
1418
function writeSeedDataIntoCache (
@@ -1462,9 +1421,8 @@ function writeSeedDataIntoCache(
1462
1421
route : FulfilledRouteCacheEntry ,
1463
1422
staleAt : number ,
1464
1423
seedData : CacheNodeSeedData ,
1465
- isResponsePartial : boolean ,
1466
1424
key : string ,
1467
- entriesOwnedByCurrentTask : Map < string , PendingSegmentCacheEntry > | null
1425
+ entriesOwnedByCurrentTask : Map < string , PendingSegmentCacheEntry >
1468
1426
) {
1469
1427
// This function is used to write the result of a dynamic server request
1470
1428
// (CacheNodeSeedData) into the prefetch cache. It's used in cases where we
@@ -1473,15 +1431,12 @@ function writeSeedDataIntoCache(
1473
1431
// dynamic data into being static) and when prefetching a PPR-disabled route
1474
1432
const rsc = seedData [ 1 ]
1475
1433
const loading = seedData [ 3 ]
1476
- const isPartial = rsc === null || isResponsePartial
1434
+ const isPartial = rsc === null
1477
1435
1478
1436
// We should only write into cache entries that are owned by us. Or create
1479
1437
// a new one and write into that. We must never write over an entry that was
1480
1438
// created by a different task, because that causes data races.
1481
- const ownedEntry =
1482
- entriesOwnedByCurrentTask !== null
1483
- ? entriesOwnedByCurrentTask . get ( key )
1484
- : undefined
1439
+ const ownedEntry = entriesOwnedByCurrentTask . get ( key )
1485
1440
if ( ownedEntry !== undefined ) {
1486
1441
fulfillSegmentCacheEntry ( ownedEntry , rsc , loading , staleAt , isPartial )
1487
1442
} else {
@@ -1526,7 +1481,6 @@ function writeSeedDataIntoCache(
1526
1481
route ,
1527
1482
staleAt ,
1528
1483
childSeedData ,
1529
- isResponsePartial ,
1530
1484
encodeChildSegmentKey (
1531
1485
key ,
1532
1486
parallelRouteKey ,
0 commit comments