Skip to content

nodejs_24: fd tracking warnings ("opened in unmanaged mode twice") on aarch64-darwin due to libcxx 21 change #536039

Description

@mortyccp

Nixpkgs version

  • Unstable (26.11)

Describe the bug

When building packages that use worker_threads with sync file I/O (e.g. pnpm 11 installing dependencies), nodejs 24.15.0+ built by nixpkgs spams warnings:

(node:7511) Warning: File descriptor 46 opened in unmanaged mode twice
(node:7511) Warning: File descriptor 46 closed but not opened in unmanaged mode

Under heavy load (e.g. GHA runners), this leads to SIGKILL and build failures.

This is a build-inputs issue, not a nodejs code issue. Upstream node builds (static linking) cannot reproduce this.

Steps to reproduce

  1. Create main.cjs:
const { Worker } = require('node:worker_threads');
const worker = new Worker(__dirname + '/worker.cjs');
worker.on('error', (e) => { console.error(e); process.exit(1); });
worker.on('exit', (c) => console.log('exited', c));
  1. Create worker.cjs:
const { openSync, readSync, closeSync } = require('node:fs');
for (let i = 0; i < 800; i++) {
  const fd = openSync('/dev/null', 'r');
  const buf = Buffer.alloc(16);
  readSync(fd, buf, 0, 16, 0);
  closeSync(fd);
}
console.log('worker: 800 sync open/read/close done');
  1. Run:
node --trace-warnings main.cjs

On the nixpkgs aarch64-darwin build of nodejs 24.15.0/24.16.0, this produces ~1599 warnings. On 24.14.1, 24.18.0, nodejs_22, and official nodejs.org builds, it produces 0 warnings.

Expected behaviour

No warnings. Sync file I/O in a worker thread should not trigger fd tracking warnings.

Screenshots

No response

Relevant log output

worker: 800 sync open/read/close done
(node:11967) Warning: File descriptor 14 closed but not opened in unmanaged mode
    at Object.<anonymous> (.../worker.cjs:8:3)
    at Module._compile (node:internal/modules/cjs/loader:1830:14)
(node:11967) Warning: File descriptor 14 opened in unmanaged mode twice
    at openSync (node:fs:561:18)
    at Object.<anonymous> (.../worker.cjs:5:14)
    at Module._compile (node:internal/modules/cjs/loader:1830:14)
... (1599 warnings total)

Additional context

Root cause

Comparing the build inputs of 24.14.1 (clean) and 24.15.0 (broken), the only meaningful difference is the libcxx version:

24.14.1 (clean) 24.15.0 (broken)
libcxx 20.1.0+apple-sdk-26.0 21.1.6+apple-sdk-26.4

The bug requires all three of:

  1. V8 13.6.233.17-node.48/.49 (shipped with node 24.15.0/24.16.0)
  2. node_shared_libuv: true (nixpkgs dynamic linking)
  3. libcxx 21.1.x (changed std::unordered_set ABI)

Removing any one of these eliminates the bug. This was verified across 4 builds:

Build V8 libcxx shared_libuv warnings
nixpkgs 24.14.1 .44 20.1.0 true 0
nixpkgs 24.15.0 .48 21.1.6 true 1601
nixpkgs 26.4.0 14.6 21.1.6 true 0
official 24.15.0 .48 Xcode 16 false 0

Each clean build removes exactly one condition: 24.14.1 uses libcxx 20 (condition 3), 26.4.0 uses a different V8 (condition 1), and the official build uses static linking (condition 2).

This issue was originally reported in #525627 as a pnpm build failure, but it is a nodejs build issue.

Fix

Pinning the stdenv to llvmPackages_20.libcxxStdenv in pkgs/development/web/nodejs/v24.nix fixes the issue:

 buildNodejs = callPackage ./nodejs.nix {
   inherit openssl;
   python = python3;
+  stdenv = buildPackages.llvmPackages_20.libcxxStdenv;
 };

I reproduced the Hydra build of 24.15.0 locally using curl https://hydra.nixos.org/build/329352653/reproduce | bash, applied this one-line change, rebuilt, and confirmed 0 warnings. The rebuilt binary is identical except for using libcxx 20.1.x instead of 21.1.x — same V8, same dynamic libuv, same everything else.

System metadata

  • system: "aarch64-darwin"
  • host os: Darwin 25.3.0, macOS 26.3.1
  • multi-user?: yes
  • sandbox: no
  • version: nix-env (Nix) 2.34.7+1
  • channels(root): "nixpkgs"
  • nixpkgs: /nix/store/gw7fxaw8z5szcqlzyzcnrshzi60zj664-source

Notify maintainers

@aduh95


Note for maintainers: Please tag this issue in your pull request description. (i.e. Resolves #ISSUE.)

I assert that this issue is relevant for Nixpkgs

Is this issue important to you?

Add a 👍 reaction to issues you find important.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions