@@ -86,7 +86,7 @@ However, I'm not confident we know all the side effects of doing this,
8686so for now, simply ensuring coordination is enough.
8787*/
8888
89- let cannotGuaranteeAtomicTimers = false
89+ let shouldAttemptPatching = false
9090
9191function warnAboutTimers ( ) {
9292 console . warn (
@@ -116,7 +116,7 @@ export function createAtomicTimerGroup(delayMs = 0) {
116116 let didImmediateRun = false
117117 function runFirstCallback ( callback : ( ) => void ) {
118118 didFirstTimerRun = true
119- if ( ! cannotGuaranteeAtomicTimers ) {
119+ if ( shouldAttemptPatching ) {
120120 setImmediate ( ( ) => {
121121 didImmediateRun = true
122122 } )
@@ -125,11 +125,11 @@ export function createAtomicTimerGroup(delayMs = 0) {
125125 }
126126
127127 function runSubsequentCallback ( callback : ( ) => void ) {
128- if ( ! cannotGuaranteeAtomicTimers ) {
128+ if ( shouldAttemptPatching ) {
129129 if ( didImmediateRun ) {
130130 // If the immediate managed to run between the timers, then we're not
131131 // able to provide the guarantees that we're supposed to
132- cannotGuaranteeAtomicTimers = true
132+ shouldAttemptPatching = false
133133 warnAboutTimers ( )
134134 }
135135 }
@@ -150,7 +150,7 @@ export function createAtomicTimerGroup(delayMs = 0) {
150150 )
151151 isFirstCallback = false
152152
153- if ( cannotGuaranteeAtomicTimers ) {
153+ if ( ! shouldAttemptPatching ) {
154154 // We already tried patching some timers, and it didn't work.
155155 // No point trying again.
156156 return timer
@@ -170,7 +170,7 @@ export function createAtomicTimerGroup(delayMs = 0) {
170170 timer . _idleStart = firstTimerIdleStart
171171 }
172172 } else {
173- cannotGuaranteeAtomicTimers = true
173+ shouldAttemptPatching = false
174174 warnAboutTimers ( )
175175 }
176176 } catch ( err ) {
@@ -182,7 +182,8 @@ export function createAtomicTimerGroup(delayMs = 0) {
182182 { cause : err }
183183 )
184184 )
185- cannotGuaranteeAtomicTimers = true
185+ shouldAttemptPatching = false
186+ warnAboutTimers ( )
186187 }
187188
188189 return timer
0 commit comments