@@ -410,31 +410,58 @@ export function getMostRecentEventTime(root: FiberRoot, lanes: Lanes): number {
410
410
}
411
411
412
412
function computeExpirationTime ( lane : Lane , currentTime : number ) {
413
- // TODO: Expiration heuristic is constant per lane, so could use a map.
414
- getHighestPriorityLanes ( lane ) ;
415
- const priority = return_highestLanePriority ;
416
- if ( priority >= InputContinuousLanePriority ) {
417
- // User interactions should expire slightly more quickly.
418
- //
419
- // NOTE: This is set to the corresponding constant as in Scheduler.js. When
420
- // we made it larger, a product metric in www regressed, suggesting there's
421
- // a user interaction that's being starved by a series of synchronous
422
- // updates. If that theory is correct, the proper solution is to fix the
423
- // starvation. However, this scenario supports the idea that expiration
424
- // times are an important safeguard when starvation does happen.
425
- //
426
- // Also note that, in the case of user input specifically, this will soon no
427
- // longer be an issue because we plan to make user input synchronous by
428
- // default (until you enter `startTransition`, of course.)
429
- //
430
- // If weren't planning to make these updates synchronous soon anyway, I
431
- // would probably make this number a configurable parameter.
432
- return currentTime + 250 ;
433
- } else if ( priority >= TransitionPriority ) {
434
- return currentTime + 5000 ;
435
- } else {
436
- // Anything idle priority or lower should never expire.
437
- return NoTimestamp ;
413
+ switch ( lane ) {
414
+ case SyncLane :
415
+ case InputContinuousHydrationLane :
416
+ case InputContinuousLane :
417
+ // User interactions should expire slightly more quickly.
418
+ //
419
+ // NOTE: This is set to the corresponding constant as in Scheduler.js.
420
+ // When we made it larger, a product metric in www regressed, suggesting
421
+ // there's a user interaction that's being starved by a series of
422
+ // synchronous updates. If that theory is correct, the proper solution is
423
+ // to fix the starvation. However, this scenario supports the idea that
424
+ // expiration times are an important safeguard when starvation
425
+ // does happen.
426
+ return currentTime + 250 ;
427
+ case DefaultHydrationLane :
428
+ case DefaultLane :
429
+ case TransitionHydrationLane :
430
+ case TransitionLane1 :
431
+ case TransitionLane2 :
432
+ case TransitionLane3 :
433
+ case TransitionLane4 :
434
+ case TransitionLane5 :
435
+ case TransitionLane6 :
436
+ case TransitionLane7 :
437
+ case TransitionLane8 :
438
+ case TransitionLane9 :
439
+ case TransitionLane10 :
440
+ case TransitionLane11 :
441
+ case TransitionLane12 :
442
+ case TransitionLane13 :
443
+ case TransitionLane14 :
444
+ case TransitionLane15 :
445
+ case TransitionLane16 :
446
+ case RetryLane1 :
447
+ case RetryLane2 :
448
+ case RetryLane3 :
449
+ case RetryLane4 :
450
+ case RetryLane5 :
451
+ return currentTime + 5000 ;
452
+ case SelectiveHydrationLane :
453
+ case IdleHydrationLane :
454
+ case IdleLane :
455
+ case OffscreenLane :
456
+ // Anything idle priority or lower should never expire.
457
+ return NoTimestamp ;
458
+ default :
459
+ if ( __DEV__ ) {
460
+ console . error (
461
+ 'Should have found matching lanes. This is a bug in React.' ,
462
+ ) ;
463
+ }
464
+ return NoTimestamp ;
438
465
}
439
466
}
440
467
0 commit comments