@@ -132,8 +132,8 @@ import {
132132 hasUpdatePriority ,
133133 getNextLanes ,
134134 returnNextLanesPriority ,
135- setCurrentLanePriority ,
136- getCurrentLanePriority ,
135+ setCurrentUpdateLanePriority ,
136+ getCurrentUpdateLanePriority ,
137137 markStarvedLanesAsExpired ,
138138 getLanesToRetrySynchronouslyOnError ,
139139 markRootUpdated ,
@@ -423,9 +423,9 @@ export function requestUpdateLane(
423423 ) ;
424424 } else if (
425425 enableCurrentLanePriority &&
426- getCurrentLanePriority ( ) !== NoLanePriority
426+ getCurrentUpdateLanePriority ( ) !== NoLanePriority
427427 ) {
428- const currentLanePriority = getCurrentLanePriority ( ) ;
428+ const currentLanePriority = getCurrentUpdateLanePriority ( ) ;
429429 lane = findUpdateLane ( currentLanePriority , currentEventWipLanes ) ;
430430 } else {
431431 // TODO: If we're not inside `runWithPriority`, this returns the priority
@@ -1078,12 +1078,12 @@ export function flushDiscreteUpdates() {
10781078
10791079export function deferredUpdates < A > ( fn : ( ) = > A ) : A {
10801080 // TODO: Remove in favor of Scheduler.next
1081- const previousLanePriority = getCurrentLanePriority ( ) ;
1081+ const previousLanePriority = getCurrentUpdateLanePriority ( ) ;
10821082 try {
1083- setCurrentLanePriority ( DefaultLanePriority ) ;
1083+ setCurrentUpdateLanePriority ( DefaultLanePriority ) ;
10841084 return runWithPriority ( NormalSchedulerPriority , fn ) ;
10851085 } finally {
1086- setCurrentLanePriority ( previousLanePriority ) ;
1086+ setCurrentUpdateLanePriority ( previousLanePriority ) ;
10871087 }
10881088}
10891089
@@ -1139,16 +1139,16 @@ export function discreteUpdates<A, B, C, D, R>(
11391139) : R {
11401140 const prevExecutionContext = executionContext ;
11411141 executionContext |= DiscreteEventContext ;
1142- const previousLanePriority = getCurrentLanePriority ( ) ;
1142+ const previousLanePriority = getCurrentUpdateLanePriority ( ) ;
11431143 try {
1144- setCurrentLanePriority ( InputDiscreteLanePriority ) ;
1144+ setCurrentUpdateLanePriority ( InputDiscreteLanePriority ) ;
11451145 // Should this
11461146 return runWithPriority (
11471147 UserBlockingSchedulerPriority ,
11481148 fn . bind ( null , a , b , c , d ) ,
11491149 ) ;
11501150 } finally {
1151- setCurrentLanePriority ( previousLanePriority ) ;
1151+ setCurrentUpdateLanePriority ( previousLanePriority ) ;
11521152 executionContext = prevExecutionContext ;
11531153 if ( executionContext === NoContext ) {
11541154 // 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 {
11851185 return fn ( a ) ;
11861186 }
11871187 executionContext |= BatchedContext ;
1188- const previousLanePriority = getCurrentLanePriority ( ) ;
1188+ const previousLanePriority = getCurrentUpdateLanePriority ( ) ;
11891189 try {
1190- setCurrentLanePriority ( SyncLanePriority ) ;
1190+ setCurrentUpdateLanePriority ( SyncLanePriority ) ;
11911191 if ( fn ) {
11921192 return runWithPriority ( ImmediateSchedulerPriority , fn . bind ( null , a ) ) ;
11931193 } else {
11941194 return ( undefined : $FlowFixMe ) ;
11951195 }
11961196 } finally {
1197- setCurrentLanePriority ( previousLanePriority ) ;
1197+ setCurrentUpdateLanePriority ( previousLanePriority ) ;
11981198 executionContext = prevExecutionContext ;
11991199 // Flush the immediate callbacks that were scheduled during this batch.
12001200 // 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 {
12061206export function flushControlled ( fn : ( ) = > mixed ) : void {
12071207 const prevExecutionContext = executionContext ;
12081208 executionContext |= BatchedContext ;
1209- const previousLanePriority = getCurrentLanePriority ( ) ;
1209+ const previousLanePriority = getCurrentUpdateLanePriority ( ) ;
12101210 try {
1211- setCurrentLanePriority ( SyncLanePriority ) ;
1211+ setCurrentUpdateLanePriority ( SyncLanePriority ) ;
12121212 runWithPriority ( ImmediateSchedulerPriority , fn ) ;
12131213 } finally {
1214- setCurrentLanePriority ( previousLanePriority ) ;
1214+ setCurrentUpdateLanePriority ( previousLanePriority ) ;
12151215 executionContext = prevExecutionContext ;
12161216 if ( executionContext === NoContext ) {
12171217 // Flush the immediate callbacks that were scheduled during this batch
@@ -1802,20 +1802,17 @@ function resetChildLanes(completedWork: Fiber) {
18021802
18031803function commitRoot ( root ) {
18041804 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+ ) ;
18151809 return null ;
18161810}
18171811
18181812function commitRootImpl ( root , renderPriorityLevel ) {
1813+ const previousLanePriority = getCurrentUpdateLanePriority ( ) ;
1814+ setCurrentUpdateLanePriority ( SyncLanePriority ) ;
1815+
18191816 do {
18201817 // `flushPassiveEffects` will call `flushSyncUpdateQueue` at the end, which
18211818 // means `flushPassiveEffects` will sometimes result in additional
@@ -2111,6 +2108,9 @@ function commitRootImpl(root, renderPriorityLevel) {
21112108 // additional work on this root is scheduled.
21122109 ensureRootIsScheduled ( root , now ( ) ) ;
21132110
2111+ // Reset the priority to the previous non-sync value.
2112+ setCurrentUpdateLanePriority ( previousLanePriority ) ;
2113+
21142114 if ( hasUncaughtError ) {
21152115 hasUncaughtError = false ;
21162116 const error = firstUncaughtError ;
@@ -2280,12 +2280,14 @@ export function flushPassiveEffects() {
22802280 ? NormalSchedulerPriority
22812281 : pendingPassiveEffectsRenderPriority ;
22822282 pendingPassiveEffectsRenderPriority = NoSchedulerPriority ;
2283- const previousLanePriority = getCurrentLanePriority ( ) ;
2283+ const previousLanePriority = getCurrentUpdateLanePriority ( ) ;
22842284 try {
2285- setCurrentLanePriority ( schedulerPriorityToLanePriority ( priorityLevel ) ) ;
2285+ setCurrentUpdateLanePriority (
2286+ schedulerPriorityToLanePriority ( priorityLevel ) ,
2287+ ) ;
22862288 return runWithPriority ( priorityLevel , flushPassiveEffectsImpl ) ;
22872289 } finally {
2288- setCurrentLanePriority ( previousLanePriority ) ;
2290+ setCurrentUpdateLanePriority ( previousLanePriority ) ;
22892291 }
22902292 }
22912293}
0 commit comments