Skip to content

fix(core): prevent batch executor error on prematurely completed tasks#35015

Merged
FrozenPandaz merged 1 commit into
masterfrom
feature/nxc-4144-batch-executor-crashes-after-a-premature-task-failure
Mar 25, 2026
Merged

fix(core): prevent batch executor error on prematurely completed tasks#35015
FrozenPandaz merged 1 commit into
masterfrom
feature/nxc-4144-batch-executor-crashes-after-a-premature-task-failure

Conversation

@lourw

@lourw lourw commented Mar 25, 2026

Copy link
Copy Markdown
Contributor

Current Behavior

When a task is prematurely completed (e.g., due to a failure that causes early termination) before its dependents have been scheduled, calling scheduleNextTasks crashes the batch executor. The crash occurs in processTaskForBatches, which traverses reverse dependencies and attempts to read notScheduledTaskGraph.dependencies[task.id] for a task that was already removed from notScheduledTaskGraph via complete(). This yields undefined for the dependencies array, causing downstream code to throw.

Expected Behavior

When a task has been prematurely completed before batch scheduling runs, processTaskForBatches should skip that task gracefully rather than crashing. Tasks that were removed from notScheduledTaskGraph early should be detected and skipped during batch traversal.

Related Issue(s)

Fixes NXC-4144

@lourw lourw requested a review from a team as a code owner March 25, 2026 15:10
@lourw lourw requested a review from FrozenPandaz March 25, 2026 15:10
@netlify

netlify Bot commented Mar 25, 2026

Copy link
Copy Markdown

Deploy Preview for nx-dev ready!

Name Link
🔨 Latest commit ce6b363
🔍 Latest deploy log https://app.netlify.com/projects/nx-dev/deploys/69c405f8d36c250008efbbda
😎 Deploy Preview https://deploy-preview-35015--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 Mar 25, 2026

Copy link
Copy Markdown

Deploy Preview for nx-docs failed. Why did it fail? →

Name Link
🔨 Latest commit ce6b363
🔍 Latest deploy log https://app.netlify.com/projects/nx-docs/deploys/69c405f885ba0e00091ff9fb

@lourw lourw changed the title fix(core): prevent batch executor crash on prematurely completed tasks fix(core): prevent batch executor error on prematurely completed tasks Mar 25, 2026
@lourw lourw self-assigned this Mar 25, 2026
@nx-cloud

nx-cloud Bot commented Mar 25, 2026

Copy link
Copy Markdown
Contributor

View your CI Pipeline Execution ↗ for commit ce6b363

Command Status Duration Result
nx affected --targets=lint,test,build,e2e,e2e-c... ✅ Succeeded 1h 1m 47s View ↗
nx run-many -t check-imports check-lock-files c... ✅ Succeeded 7s View ↗
nx-cloud record -- pnpm nx conformance:check ✅ Succeeded 7s View ↗
nx build workspace-plugin ✅ Succeeded 1m 44s View ↗
nx-cloud record -- nx format:check ✅ Succeeded 2s View ↗
nx-cloud record -- nx sync:check ✅ Succeeded <1s View ↗

☁️ Nx Cloud last updated this comment at 2026-03-25 17:05:36 UTC

@FrozenPandaz FrozenPandaz force-pushed the feature/nxc-4144-batch-executor-crashes-after-a-premature-task-failure branch 3 times, most recently from 8374438 to e5cfb7c Compare March 25, 2026 15:55
When a task is completed before its dependents are scheduled,
processTaskForBatches would crash trying to read dependencies
for a task already removed from notScheduledTaskGraph. Clean up
reverseTaskDeps in complete() so batch traversal never reaches
completed tasks.
@FrozenPandaz FrozenPandaz force-pushed the feature/nxc-4144-batch-executor-crashes-after-a-premature-task-failure branch from e5cfb7c to ce6b363 Compare March 25, 2026 15:57
@FrozenPandaz FrozenPandaz merged commit f003f56 into master Mar 25, 2026
20 of 24 checks passed
@FrozenPandaz FrozenPandaz deleted the feature/nxc-4144-batch-executor-crashes-after-a-premature-task-failure branch March 25, 2026 17:41
FrozenPandaz pushed a commit that referenced this pull request Mar 26, 2026
#35015)

## Current Behavior

When a task is prematurely completed (e.g., due to a failure that causes
early termination) before its dependents have been scheduled, calling
`scheduleNextTasks` crashes the batch executor. The crash occurs in
`processTaskForBatches`, which traverses reverse dependencies and
attempts to read `notScheduledTaskGraph.dependencies[task.id]` for a
task that was already removed from `notScheduledTaskGraph` via
`complete()`. This yields `undefined` for the dependencies array,
causing downstream code to throw.

## Expected Behavior

When a task has been prematurely completed before batch scheduling runs,
`processTaskForBatches` should skip that task gracefully rather than
crashing. Tasks that were removed from `notScheduledTaskGraph` early
should be detected and skipped during batch traversal.

## Related Issue(s)

Fixes NXC-4144

(cherry picked from commit f003f56)
@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 Mar 31, 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