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