发布

  • fix(core): kill discrete tasks and use tree-kill for batch cleanup on SIGINT (#35175)

    frostbyte_neo 发布于 2026-04-07 23:00:49 +00:00

    Current Behavior

    When Nx receives SIGINT (Ctrl+C), performCleanup() in the task
    orchestrator kills continuous tasks and run-commands tasks, but not
    discrete tasks
    (executor-based builds like @nx/js:tsc,
    nx:run-script, etc.). In TUI mode, fork workers run in separate PTY
    process groups and don't receive SIGINT directly, so cleanup hangs
    waiting for tasks that are never terminated.

    Additionally, BatchProcess.kill() only sends a signal to the immediate
    child process, leaving grandchild processes (e.g. Java JVM, Gradle
    daemon, Gradle workers) alive.

    The Gradle batch executor also uses execSync, which blocks the Node
    event loop and prevents the worker from responding to signals.

    Expected Behavior

    All task types — discrete, continuous, and run-commands — should be
    explicitly killed during SIGINT cleanup. Batch processes should use
    tree-kill to terminate the entire process tree. The Gradle batch
    executor should use async spawn instead of blocking execSync.

    Related Issue(s)

    N/A — found via code inspection and confirmed with tests.

    下载附件