fix(core): await queued processTask promises before cache.getBatch - #35322
Conversation
✅ Deploy Preview for nx-dev ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
✅ Deploy Preview for nx-docs ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
|
View your CI Pipeline Execution ↗ for commit fc29c6e
☁️ Nx Cloud last updated this comment at |
There was a problem hiding this comment.
Nx Cloud has identified a flaky task in your failed CI:
🔂 Since the failure was identified as flaky, we triggered a CI rerun by adding an empty commit to this branch.
🔔 Heads up, your workspace has pending recommendations ↗ to auto-apply fixes for similar failures.
🎓 Learn more about Self-Healing CI on nx.dev
|
This pull request has already been merged/closed. If you experience issues related to these changes, please open a new issue referencing this pull request. |
Current Behavior
Nx Cloud agents crash on warm-cache runs with:
Regression introduced by #35172 (warm-cache perf optimization). Cloud agents call
runDiscreteTaskswithtask.hash = null(they intentionally null hashes — seeocean/.../execute-tasks-v3.ts).init-tasks-runner.ts::createOrchestratorqueuesprocessTaskpromises via fire-and-forgetprocessAllScheduledTasks(), butrunDiscreteTasksimmediately callsresolveCachedTaskswhich doesn't await them.cache.getBatch(tasks.map(t => t.hash))then receives nulls and the napi binding rejects them.Expected Behavior
resolveCachedTasksawaits the queuedprocessTaskpromises (which settask.hashviahashTask) before passing hashes intocache.getBatch.The single-task
runTaskDirectlypath already awaitsthis.processedTasks.get(task.id)for the same reason — this fix mirrors that pattern in the bulk path.Bonus: a second tiny commit changes coordinator step 1's pre-hash guard from
unhashed.length > 1to> 0. The> 1micro-optimization silently skipped cache lookup for single-task cycles, becauseresolveCachedTasksBulkfilters candidates bytask.hash &&— a length-1 unhashed task got dropped and ran without a cache check. Cost more in lost cache hits than it saved in batch setup.Related Issue(s)
Surfaced internally; no GitHub issue.