File tree Expand file tree Collapse file tree 1 file changed +5
-11
lines changed Expand file tree Collapse file tree 1 file changed +5
-11
lines changed Original file line number Diff line number Diff line change @@ -81,15 +81,15 @@ function waitFor(
8181 jest . advanceTimersByTime ( interval )
8282 } )
8383
84+ // Could have timed-out
85+ if ( finished ) {
86+ break
87+ }
8488 // It's really important that checkCallback is run *before* we flush
8589 // in-flight promises. To be honest, I'm not sure why, and I can't quite
8690 // think of a way to reproduce the problem in a test, but I spent
8791 // an entire day banging my head against a wall on this.
8892 checkCallback ( )
89-
90- if ( finished ) {
91- break
92- }
9393 }
9494 } else {
9595 try {
@@ -106,9 +106,6 @@ function waitFor(
106106 }
107107
108108 function onDone ( error , result ) {
109- if ( finished ) {
110- return
111- }
112109 finished = true
113110 clearTimeout ( overallTimeoutTimer )
114111
@@ -137,7 +134,7 @@ function waitFor(
137134 }
138135
139136 function checkCallback ( ) {
140- if ( finished || promiseStatus === 'pending' ) return
137+ if ( promiseStatus === 'pending' ) return
141138 try {
142139 const result = runWithExpensiveErrorDiagnosticsDisabled ( callback )
143140 if ( typeof result ?. then === 'function' ) {
@@ -163,9 +160,6 @@ function waitFor(
163160 }
164161
165162 function handleTimeout ( ) {
166- if ( finished ) {
167- return
168- }
169163 let error
170164 if ( lastError ) {
171165 error = lastError
You can’t perform that action at this time.
0 commit comments