Skip to content

Commit 7a6cc1e

Browse files
committed
Decrease expiration time of input updates
Changes the expiration time of input updates from 1000ms to 250ms, to match the corresponding constant in Scheduler.js. When we made it larger, a product metric in www regressed, suggesting there's a user interaction that's being starved by a series of synchronous updates. If that theory is correct, the proper solution is to fix the starvation. However, this scenario supports the idea that expiration times are an important safeguard when starvation does happen. Also note that, in the case of user input specifically, this will soon no longer be an issue because we plan to make user input synchronous by default (until you enter `startTransition`, of course.) If weren't planning to make these updates synchronous soon anyway, I would probably make this number a configurable parameter.
1 parent 36df483 commit 7a6cc1e

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

packages/react-reconciler/src/ReactFiberLane.js

+15-1
Original file line numberDiff line numberDiff line change
@@ -384,7 +384,21 @@ function computeExpirationTime(lane: Lane, currentTime: number) {
384384
const priority = return_highestLanePriority;
385385
if (priority >= InputContinuousLanePriority) {
386386
// User interactions should expire slightly more quickly.
387-
return currentTime + 1000;
387+
//
388+
// NOTE: This is set to the corresponding constant as in Scheduler.js. When
389+
// we made it larger, a product metric in www regressed, suggesting there's
390+
// a user interaction that's being starved by a series of synchronous
391+
// updates. If that theory is correct, the proper solution is to fix the
392+
// starvation. However, this scenario supports the idea that expiration
393+
// times are an important safeguard when starvation does happen.
394+
//
395+
// Also note that, in the case of user input specifically, this will soon no
396+
// longer be an issue because we plan to make user input by default (until
397+
// you enter `startTransition`, of course.)
398+
//
399+
// If weren't planning to make these updates synchronous soon anyway, I
400+
// would probably make this number a configurable parameter.
401+
return currentTime + 250;
388402
} else if (priority >= TransitionPriority) {
389403
return currentTime + 5000;
390404
} else {

0 commit comments

Comments
 (0)