Skip to content

Commit d25f793

Browse files
authored
Merge pull request #363 from felthy/master
Prevent Chrome DevTools pausing on Promise rejection when fonts load successfully
2 parents fd70d89 + c987fdf commit d25f793

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

src/core/nativefontwatchrunner.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,16 @@ goog.scope(function () {
5151
check();
5252
});
5353

54-
var timer = new Promise(function (resolve, reject) {
55-
setTimeout(reject, that.timeout_);
56-
});
54+
var timeoutId = null,
55+
timer = new Promise(function (resolve, reject) {
56+
timeoutId = setTimeout(reject, that.timeout_);
57+
});
5758

5859
Promise.race([timer, loader]).then(function () {
60+
if (timeoutId) {
61+
clearTimeout(timeoutId);
62+
timeoutId = null;
63+
}
5964
that.activeCallback_(that.font_);
6065
}, function () {
6166
that.inactiveCallback_(that.font_);

0 commit comments

Comments
 (0)