From c987fdfbe8ff590687d57547b7174c157bdf3ada Mon Sep 17 00:00:00 2001 From: Pete Feltham Date: Thu, 4 May 2017 12:48:37 +1000 Subject: [PATCH] Prevent the timeout Promise from being rejected in NativeFontWatchRunner after the loader promise has already resolved; to prevent Chrome DevTools from pausing. Fixes #362 --- src/core/nativefontwatchrunner.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/core/nativefontwatchrunner.js b/src/core/nativefontwatchrunner.js index 55f360d5..d6f46365 100644 --- a/src/core/nativefontwatchrunner.js +++ b/src/core/nativefontwatchrunner.js @@ -51,11 +51,16 @@ goog.scope(function () { check(); }); - var timer = new Promise(function (resolve, reject) { - setTimeout(reject, that.timeout_); - }); + var timeoutId = null, + timer = new Promise(function (resolve, reject) { + timeoutId = setTimeout(reject, that.timeout_); + }); Promise.race([timer, loader]).then(function () { + if (timeoutId) { + clearTimeout(timeoutId); + timeoutId = null; + } that.activeCallback_(that.font_); }, function () { that.inactiveCallback_(that.font_);