Skip to content

fix(os): keep availableParallelism independent of navigator - #178

Merged
steipete merged 1 commit into
mainfrom
claude/fix-available-parallelism-global
Oct 16, 2026
Merged

steipete merged 1 commit into
mainfrom
claude/fix-available-parallelism-global

Conversation

@steipete

@steipete steipete commented Oct 16, 2026 •

Copy link
Copy Markdown

What does this PR do?

Keep os.availableParallelism() independent of the mutable global navigator object. Replacing that object with a media-device shim currently makes the function return undefined; deleting it or installing a throwing getter can make it throw.

Call the existing native hardware-concurrency getter directly, preserving its CPU affinity and cgroup behavior. Add regression cases that delete or replace navigator, or install throwing getters on it and on hardwareConcurrency, both before and after importing node:os.

Upstream main still reads navigator.hardwareConcurrency. The broader native-binding approach in oven-sh#41556 also avoids this global lookup, but it requires unmerged WebKit changes to refresh CPU affinity/quota on every call. This patch uses the existing native getter and preserves the current CPU-count policy. Thanks robobun for the related upstream work. Related affinity issue: oven-sh#29129.

How did you verify your code works?

  • Node 24.22.0 passes all eight mutation cases; the unpatched Bun build fails all eight.
  • A native Linux release build passes all 71 tests in test/js/node/os, including both-runtime regression cases.
  • Commands: bun run build:release --lto=off, then bun run build:release --lto=off test test/js/node/os.
  • The regression covers mutations before and after module import, and verifies throwing getters are never invoked.

@steipete
steipete marked this pull request as ready for review October 16, 2026 10:52
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 16, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-16T10:54:20.645503Z 4dd257b Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@steipete
steipete merged commit 4bae38f into main Oct 16, 2026
7 of 8 checks passed
@steipete
steipete deleted the claude/fix-available-parallelism-global branch October 16, 2026 10:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant