@@ -132,8 +132,8 @@ import {
132
132
hasUpdatePriority ,
133
133
getNextLanes ,
134
134
returnNextLanesPriority ,
135
- setCurrentLanePriority ,
136
- getCurrentLanePriority ,
135
+ setCurrentUpdateLanePriority ,
136
+ getCurrentUpdateLanePriority ,
137
137
markStarvedLanesAsExpired ,
138
138
getLanesToRetrySynchronouslyOnError ,
139
139
markRootUpdated ,
@@ -423,9 +423,9 @@ export function requestUpdateLane(
423
423
) ;
424
424
} else if (
425
425
enableCurrentLanePriority &&
426
- getCurrentLanePriority ( ) !== NoLanePriority
426
+ getCurrentUpdateLanePriority ( ) !== NoLanePriority
427
427
) {
428
- const currentLanePriority = getCurrentLanePriority ( ) ;
428
+ const currentLanePriority = getCurrentUpdateLanePriority ( ) ;
429
429
lane = findUpdateLane ( currentLanePriority , currentEventWipLanes ) ;
430
430
} else {
431
431
// TODO: If we're not inside `runWithPriority`, this returns the priority
@@ -1078,12 +1078,12 @@ export function flushDiscreteUpdates() {
1078
1078
1079
1079
export function deferredUpdates < A > ( fn : ( ) = > A ) : A {
1080
1080
// TODO: Remove in favor of Scheduler.next
1081
- const previousLanePriority = getCurrentLanePriority ( ) ;
1081
+ const previousLanePriority = getCurrentUpdateLanePriority ( ) ;
1082
1082
try {
1083
- setCurrentLanePriority ( DefaultLanePriority ) ;
1083
+ setCurrentUpdateLanePriority ( DefaultLanePriority ) ;
1084
1084
return runWithPriority ( NormalSchedulerPriority , fn ) ;
1085
1085
} finally {
1086
- setCurrentLanePriority ( previousLanePriority ) ;
1086
+ setCurrentUpdateLanePriority ( previousLanePriority ) ;
1087
1087
}
1088
1088
}
1089
1089
@@ -1139,16 +1139,16 @@ export function discreteUpdates<A, B, C, D, R>(
1139
1139
) : R {
1140
1140
const prevExecutionContext = executionContext ;
1141
1141
executionContext |= DiscreteEventContext ;
1142
- const previousLanePriority = getCurrentLanePriority ( ) ;
1142
+ const previousLanePriority = getCurrentUpdateLanePriority ( ) ;
1143
1143
try {
1144
- setCurrentLanePriority ( InputDiscreteLanePriority ) ;
1144
+ setCurrentUpdateLanePriority ( InputDiscreteLanePriority ) ;
1145
1145
// Should this
1146
1146
return runWithPriority (
1147
1147
UserBlockingSchedulerPriority ,
1148
1148
fn . bind ( null , a , b , c , d ) ,
1149
1149
) ;
1150
1150
} finally {
1151
- setCurrentLanePriority ( previousLanePriority ) ;
1151
+ setCurrentUpdateLanePriority ( previousLanePriority ) ;
1152
1152
executionContext = prevExecutionContext ;
1153
1153
if ( executionContext === NoContext ) {
1154
1154
// Flush the immediate callbacks that were scheduled during this batch
@@ -1185,16 +1185,16 @@ export function flushSync<A, R>(fn: A => R, a: A): R {
1185
1185
return fn ( a ) ;
1186
1186
}
1187
1187
executionContext |= BatchedContext ;
1188
- const previousLanePriority = getCurrentLanePriority ( ) ;
1188
+ const previousLanePriority = getCurrentUpdateLanePriority ( ) ;
1189
1189
try {
1190
- setCurrentLanePriority ( SyncLanePriority ) ;
1190
+ setCurrentUpdateLanePriority ( SyncLanePriority ) ;
1191
1191
if ( fn ) {
1192
1192
return runWithPriority ( ImmediateSchedulerPriority , fn . bind ( null , a ) ) ;
1193
1193
} else {
1194
1194
return ( undefined : $FlowFixMe ) ;
1195
1195
}
1196
1196
} finally {
1197
- setCurrentLanePriority ( previousLanePriority ) ;
1197
+ setCurrentUpdateLanePriority ( previousLanePriority ) ;
1198
1198
executionContext = prevExecutionContext ;
1199
1199
// Flush the immediate callbacks that were scheduled during this batch.
1200
1200
// Note that this will happen even if batchedUpdates is higher up
@@ -1206,12 +1206,12 @@ export function flushSync<A, R>(fn: A => R, a: A): R {
1206
1206
export function flushControlled ( fn : ( ) = > mixed ) : void {
1207
1207
const prevExecutionContext = executionContext ;
1208
1208
executionContext |= BatchedContext ;
1209
- const previousLanePriority = getCurrentLanePriority ( ) ;
1209
+ const previousLanePriority = getCurrentUpdateLanePriority ( ) ;
1210
1210
try {
1211
- setCurrentLanePriority ( SyncLanePriority ) ;
1211
+ setCurrentUpdateLanePriority ( SyncLanePriority ) ;
1212
1212
runWithPriority ( ImmediateSchedulerPriority , fn ) ;
1213
1213
} finally {
1214
- setCurrentLanePriority ( previousLanePriority ) ;
1214
+ setCurrentUpdateLanePriority ( previousLanePriority ) ;
1215
1215
executionContext = prevExecutionContext ;
1216
1216
if ( executionContext === NoContext ) {
1217
1217
// Flush the immediate callbacks that were scheduled during this batch
@@ -1802,20 +1802,17 @@ function resetChildLanes(completedWork: Fiber) {
1802
1802
1803
1803
function commitRoot ( root ) {
1804
1804
const renderPriorityLevel = getCurrentPriorityLevel ( ) ;
1805
- const previousLanePriority = getCurrentLanePriority ( ) ;
1806
- try {
1807
- setCurrentLanePriority ( SyncLanePriority ) ;
1808
- runWithPriority (
1809
- ImmediateSchedulerPriority ,
1810
- commitRootImpl . bind ( null , root , renderPriorityLevel ) ,
1811
- ) ;
1812
- } finally {
1813
- setCurrentLanePriority ( previousLanePriority ) ;
1814
- }
1805
+ runWithPriority (
1806
+ ImmediateSchedulerPriority ,
1807
+ commitRootImpl . bind ( null , root , renderPriorityLevel ) ,
1808
+ ) ;
1815
1809
return null ;
1816
1810
}
1817
1811
1818
1812
function commitRootImpl ( root , renderPriorityLevel ) {
1813
+ const previousLanePriority = getCurrentUpdateLanePriority ( ) ;
1814
+ setCurrentUpdateLanePriority ( SyncLanePriority ) ;
1815
+
1819
1816
do {
1820
1817
// `flushPassiveEffects` will call `flushSyncUpdateQueue` at the end, which
1821
1818
// means `flushPassiveEffects` will sometimes result in additional
@@ -2111,6 +2108,9 @@ function commitRootImpl(root, renderPriorityLevel) {
2111
2108
// additional work on this root is scheduled.
2112
2109
ensureRootIsScheduled ( root , now ( ) ) ;
2113
2110
2111
+ // Reset the priority to the previous non-sync value.
2112
+ setCurrentUpdateLanePriority ( previousLanePriority ) ;
2113
+
2114
2114
if ( hasUncaughtError ) {
2115
2115
hasUncaughtError = false ;
2116
2116
const error = firstUncaughtError ;
@@ -2280,12 +2280,14 @@ export function flushPassiveEffects() {
2280
2280
? NormalSchedulerPriority
2281
2281
: pendingPassiveEffectsRenderPriority ;
2282
2282
pendingPassiveEffectsRenderPriority = NoSchedulerPriority ;
2283
- const previousLanePriority = getCurrentLanePriority ( ) ;
2283
+ const previousLanePriority = getCurrentUpdateLanePriority ( ) ;
2284
2284
try {
2285
- setCurrentLanePriority ( schedulerPriorityToLanePriority ( priorityLevel ) ) ;
2285
+ setCurrentUpdateLanePriority (
2286
+ schedulerPriorityToLanePriority ( priorityLevel ) ,
2287
+ ) ;
2286
2288
return runWithPriority ( priorityLevel , flushPassiveEffectsImpl ) ;
2287
2289
} finally {
2288
- setCurrentLanePriority ( previousLanePriority ) ;
2290
+ setCurrentUpdateLanePriority ( previousLanePriority ) ;
2289
2291
}
2290
2292
}
2291
2293
}
0 commit comments