From 93b7acf99d6456e6e194c03f024b788ce5adf20e Mon Sep 17 00:00:00 2001 From: Bert Belder Date: Fri, 20 Sep 2019 00:09:43 +0200 Subject: js: reschedule global timer if it fires earlier than expected (#2989) When the global timer fires earlier than expected, which apparently happens sometimes on server editions of Windows, we didn't call any setTimeout callbacks, but we *also* didn't reschedule the global timer to fire again later. When this situation occurred it would make deno exit abruptly if there were no other asynchronous ops running on the event loop. It could also lead to application hangs if the upcoming setTimeout callback was critical for the application to make progress. --- js/timers.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'js') diff --git a/js/timers.ts b/js/timers.ts index ff8df9a6b..5bc4922e3 100644 --- a/js/timers.ts +++ b/js/timers.ts @@ -138,8 +138,8 @@ function fire(timer: Timer): void { function fireTimers(): void { const now = getTime(); - // Bail out if we're not expecting the global timer to fire (yet). - if (globalTimeoutDue === null || now < globalTimeoutDue) { + // Bail out if we're not expecting the global timer to fire. + if (globalTimeoutDue === null) { return; } // After firing the timers that are due now, this will hold the due time of -- cgit v1.2.3