From d29efb7f81811e48bd7d84da26a6d93d9f90e245 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Thu, 7 Aug 2014 10:37:00 +0800 Subject: [PATCH] Force updating timeout when setTimeout is called, fixes #481. --- atom/common/lib/init.coffee | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/atom/common/lib/init.coffee b/atom/common/lib/init.coffee index 5da0274427..0d5e8e6b49 100644 --- a/atom/common/lib/init.coffee +++ b/atom/common/lib/init.coffee @@ -25,3 +25,10 @@ wrapWithActivateUvLoop = (func) -> process.nextTick = wrapWithActivateUvLoop process.nextTick global.setImmediate = wrapWithActivateUvLoop timers.setImmediate global.clearImmediate = timers.clearImmediate + +# setTimeout needs to update the polling timeout of the event loop, when called +# under Chromium's event loop the node's event loop won't get a chance to update +# the timeout, so we have to force the node's event loop to recalculate the +# timeout in browser process. +if process.type is 'browser' + global.setTimeout = wrapWithActivateUvLoop timers.setTimeout