Skip to content

Commit

Permalink
fix(core): measure perf for async checks (#4609)
Browse files Browse the repository at this point in the history
Performance of async checks isn't measured correctly. No tests, since we
don't generally test perf timer stuff.
  • Loading branch information
WilcoFiers authored Nov 1, 2024
1 parent 61dd5e3 commit 7e9bacf
Showing 1 changed file with 15 additions and 9 deletions.
24 changes: 15 additions & 9 deletions lib/core/base/rule.js
Original file line number Diff line number Diff line change
Expand Up @@ -284,15 +284,21 @@ Rule.prototype.run = function run(context, options = {}, resolve, reject) {
});
});

// Defer the rule's execution to prevent "unresponsive script" warnings.
// See https://github.com/dequelabs/axe-core/pull/1172 for discussion and details.
q.defer(res => setTimeout(res, 0));

if (options.performanceTimer) {
this._logRulePerformance();
}

q.then(() => resolve(ruleResult)).catch(error => reject(error));
q.then(() => {
if (options.performanceTimer) {
this._logRulePerformance();
}
// Defer the rule's execution to prevent "unresponsive script" warnings.
// See https://github.com/dequelabs/axe-core/pull/1172 for discussion and details.
setTimeout(() => {
resolve(ruleResult);
}, 0);
}).catch(error => {
if (options.performanceTimer) {
this._logRulePerformance();
}
reject(error);
});
};

/**
Expand Down

0 comments on commit 7e9bacf

Please sign in to comment.