Skip to content

Build/Test Tools: Stop builds hanging on Node.js 24 shutdown - #13608

Open
manzoorwanijk wants to merge 1 commit into
WordPress:trunkfrom
manzoorwanijk:fix/build-hang-node24-maglev
Open

manzoorwanijk wants to merge 1 commit into
WordPress:trunkfrom
manzoorwanijk:fix/build-hang-node24-maglev

Conversation

@manzoorwanijk

@manzoorwanijk manzoorwanijk commented Sep 18, 2026

Copy link
Copy Markdown
Member

Runs Grunt with V8's concurrent Maglev and Sparkplug compilers disabled, so builds stop hanging after Done..

Grunt ends a successful run with process.exit(0) (grunt.js:163). Node's exit handler joins the V8 platform worker pool, and when a background compile job is parked in CollectionBarrier::AwaitCollectionBackground waiting for a garbage collection the main thread can no longer run, the two deadlock:

main thread   node::Environment::Exit -> DisposePlatform -> NodePlatform::Shutdown
              -> WorkerThreadsTaskRunner::Shutdown -> uv_thread_join      [blocked]

V8Worker x2   MaglevConcurrentDispatcher::JobTask::Run -> MaglevCompiler::Compile
              -> HeapAllocator::AllocateRawWithRetryOrFailSlowPath
              -> CollectionBarrier::AwaitCollectionBackground             [blocked]

Node 24 turns on both --maglev and --concurrent-sparkplug, where Node 22 had neither, which is why this started with r63539. --concurrent-recompilation was already on under Node 22 and costs 2.2x build time to disable, so it is left alone. Upstream: nodejs/node#64274.

NODE_OPTIONS rejects V8 options, so tools/grunt.js carries them instead and every Grunt entry point routes through it. That includes the grunt script CI calls and the nested child in utils.js:234.

Previous attempts to contain this by timeout: #13564, r63643, r63647.

Testing instructions

  1. Run npm run build:dev and confirm the process exits rather than stalling after Done..
  2. Run npm run grunt jshint and confirm the exit code still propagates.

On macOS arm64 with Node 24.21.0 the stall appeared in 3 of 60 unpatched runs, always with the stack above, caught by running sample(1) on a process still alive after Done..

Trac ticket: https://core.trac.wordpress.org/ticket/66116

Use of AI Tools

AI assistance: Yes
Tool(s): Claude Code, Codex
Model(s): Claude Opus 5, GPT-5.3 Codex
Used for: Diagnosis, the native stacks, and drafting and reviewing the launcher. I verified the stacks, measurements and final change myself.

Grunt ends a run with `process.exit()`. Node's exit handler joins the V8
platform worker pool, and when a background compile job is parked waiting
for a garbage collection the main thread can no longer run, the two
deadlock and the build never exits.

Node.js 24 turns on both `--maglev` and `--concurrent-sparkplug`, where
Node.js 22 had neither, which is what made this reachable. `NODE_OPTIONS`
rejects V8 options, so a launcher passes them on the command line and
every Grunt entry point routes through it.

See nodejs/node#64274.

See #66116.
@github-actions

Copy link
Copy Markdown

Test using WordPress Playground

The changes in this pull request can previewed and tested using a WordPress Playground instance.

WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser.

Some things to be aware of

  • All changes will be lost when closing a tab with a Playground instance.
  • All changes will be lost when refreshing the page.
  • A fresh instance is created each time the link below is clicked.
  • Every time this pull request is updated, a new ZIP file containing all changes is created. If changes are not reflected in the Playground instance,
    it's possible that the most recent build failed, or has not completed. Check the list of workflow runs to be sure.

For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation.

Test this pull request with WordPress Playground.

@manzoorwanijk
manzoorwanijk marked this pull request as ready for review September 18, 2026 14:32
@github-actions

Copy link
Copy Markdown

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

Core Committers: Use this line as a base for the props when committing in SVN:

Props manzoorwanijk.

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: In review

Development

Successfully merging this pull request may close these issues.

2 participants