Skip to content

Commit 3357072

Browse files
chikara1608claude
andcommitted
perf(rule): resolve rule results synchronously instead of via setTimeout(0)
The setTimeout(0) wrapper around resolve(ruleResult) created 335 macrotask transitions per scan. On large DOMs with advance ON, these interleave with concurrent DevTools IPC calls (resource.getContent), inflating axe.run from ~14s to ~85s. Resolving synchronously eliminates the contention. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 52f726f commit 3357072

1 file changed

Lines changed: 4 additions & 5 deletions

File tree

lib/core/base/rule.js

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -310,11 +310,10 @@ Rule.prototype.run = function run(context, options = {}, resolve, reject) {
310310
if (options.performanceTimer) {
311311
this._logRulePerformance();
312312
}
313-
// Defer the rule's execution to prevent "unresponsive script" warnings.
314-
// See https://github.com/dequelabs/axe-core/pull/1172 for discussion and details.
315-
setTimeout(() => {
316-
resolve(ruleResult);
317-
}, 0);
313+
// [a11y-core]: resolve synchronously — the setTimeout(0) caused 335
314+
// macrotask transitions that interleave with DevTools IPC (resource.getContent),
315+
// inflating axe.run from ~14s to ~85s on large DOMs with advance ON.
316+
resolve(ruleResult);
318317
}).catch(error => {
319318
if (options.performanceTimer) {
320319
this._logRulePerformance();

0 commit comments

Comments
 (0)