Skip to content

fix(core): await queued processTask promises before cache.getBatch - #35322

Merged
FrozenPandaz merged 4 commits into
masterfrom
fix/getbatch-null-hash
Apr 17, 2026
Merged

fix(core): await queued processTask promises before cache.getBatch#35322
FrozenPandaz merged 4 commits into
masterfrom
fix/getbatch-null-hash

Conversation

@FrozenPandaz

@FrozenPandaz FrozenPandaz commented Apr 17, 2026

Copy link
Copy Markdown
Contributor

Current Behavior

Nx Cloud agents crash on warm-cache runs with:

Error: Failed to convert JavaScript value `Null` into rust type `String`
    at DbCache.getBatch (.../cache.js:115:41)
    at TaskOrchestrator.fetchCacheHits (.../task-orchestrator.js:270:47)
    at TaskOrchestrator.resolveCachedTasks (.../task-orchestrator.js:564:38)
    at runDiscreteTasks (.../init-tasks-runner.js:133:42)
  code: 'StringExpected'

Regression introduced by #35172 (warm-cache perf optimization). Cloud agents call runDiscreteTasks with task.hash = null (they intentionally null hashes — see ocean/.../execute-tasks-v3.ts). init-tasks-runner.ts::createOrchestrator queues processTask promises via fire-and-forget processAllScheduledTasks(), but runDiscreteTasks immediately calls resolveCachedTasks which doesn't await them. cache.getBatch(tasks.map(t => t.hash)) then receives nulls and the napi binding rejects them.

Expected Behavior

resolveCachedTasks awaits the queued processTask promises (which set task.hash via hashTask) before passing hashes into cache.getBatch.

The single-task runTaskDirectly path already awaits this.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 > 1 to > 0. The > 1 micro-optimization silently skipped cache lookup for single-task cycles, because resolveCachedTasksBulk filters candidates by task.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.

@netlify

netlify Bot commented Apr 17, 2026

Copy link
Copy Markdown

Deploy Preview for nx-dev ready!

Name Link
🔨 Latest commit fc29c6e
🔍 Latest deploy log https://app.netlify.com/projects/nx-dev/deploys/69e1e0b804b39200087e085b
😎 Deploy Preview https://deploy-preview-35322--nx-dev.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@netlify

netlify Bot commented Apr 17, 2026

Copy link
Copy Markdown

Deploy Preview for nx-docs ready!

Name Link
🔨 Latest commit fc29c6e
🔍 Latest deploy log https://app.netlify.com/projects/nx-docs/deploys/69e1e0b89e8bb20008d576ae
😎 Deploy Preview https://deploy-preview-35322--nx-docs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@nx-cloud

nx-cloud Bot commented Apr 17, 2026

Copy link
Copy Markdown
Contributor

View your CI Pipeline Execution ↗ for commit fc29c6e

Command Status Duration Result
nx affected --targets=lint,test,build,e2e,e2e-c... ✅ Succeeded 30m 45s View ↗
nx run-many -t check-imports check-lock-files c... ✅ Succeeded 6s View ↗
nx-cloud record -- pnpm nx-cloud conformance:check ✅ Succeeded 18s View ↗
nx build workspace-plugin ✅ Succeeded <1s View ↗
nx-cloud record -- nx sync:check ✅ Succeeded 25s View ↗
nx-cloud record -- nx format:check ✅ Succeeded 15s View ↗

☁️ Nx Cloud last updated this comment at 2026-04-17 13:34:17 UTC

nx-cloud[bot]

This comment was marked as outdated.

@nx-cloud nx-cloud Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Nx Cloud View detailed reasoning in Nx Cloud ↗

🔔 Heads up, your workspace has pending recommendations ↗ to auto-apply fixes for similar failures.


🎓 Learn more about Self-Healing CI on nx.dev

@FrozenPandaz
FrozenPandaz marked this pull request as ready for review April 17, 2026 12:57
@FrozenPandaz
FrozenPandaz requested a review from a team as a code owner April 17, 2026 12:57
@FrozenPandaz
FrozenPandaz requested a review from JamesHenry April 17, 2026 12:57
@FrozenPandaz
FrozenPandaz merged commit b1717a6 into master Apr 17, 2026
25 of 26 checks passed
@FrozenPandaz
FrozenPandaz deleted the fix/getbatch-null-hash branch April 17, 2026 15:48
@github-actions

Copy link
Copy Markdown
Contributor

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.

@github-actions github-actions Bot locked as resolved and limited conversation to collaborators Apr 23, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants