File tree 2 files changed +13
-9
lines changed 2 files changed +13
-9
lines changed Original file line number Diff line number Diff line change @@ -976,6 +976,15 @@ export function makeInterruptibleAsyncInterval(
976
976
// never completes, the `timeUntilNextCall` will continue to grow
977
977
// negatively unbounded, so it will never trigger a reschedule here.
978
978
979
+ // This is possible in virtualized environments like AWS Lambda where our
980
+ // clock is unreliable. In these cases the timer is "running" but never
981
+ // actually completes, so we want to execute immediately and then attempt
982
+ // to reschedule.
983
+ if ( timeUntilNextCall < 0 ) {
984
+ executeAndReschedule ( ) ;
985
+ return ;
986
+ }
987
+
979
988
// debounce multiple calls to wake within the `minInterval`
980
989
if ( timeSinceLastWake < minInterval ) {
981
990
return ;
@@ -986,14 +995,6 @@ export function makeInterruptibleAsyncInterval(
986
995
if ( timeUntilNextCall > minInterval ) {
987
996
reschedule ( minInterval ) ;
988
997
}
989
-
990
- // This is possible in virtualized environments like AWS Lambda where our
991
- // clock is unreliable. In these cases the timer is "running" but never
992
- // actually completes, so we want to execute immediately and then attempt
993
- // to reschedule.
994
- if ( timeUntilNextCall < 0 ) {
995
- executeAndReschedule ( ) ;
996
- }
997
998
}
998
999
999
1000
function stop ( ) {
Original file line number Diff line number Diff line change @@ -140,8 +140,11 @@ describe('utils', function () {
140
140
141
141
// needs to happen on the third call because `wake` checks
142
142
// the `currentTime` at the beginning of the function
143
+ // The value of now() is not actually negative in the case of
144
+ // the unreliable check so we force to a negative value now
145
+ // for this test.
143
146
if ( clockCalled === 3 ) {
144
- return now ( ) - 100000 ;
147
+ return - 1 ;
145
148
}
146
149
147
150
return now ( ) ;
You can’t perform that action at this time.
0 commit comments