Skip to content

fix(core): keep Node's conditions container type in the resolve hook - #37576

Open
sarankumar1325 wants to merge 1 commit into
nrwl:masterfrom
sarankumar1325:fix/register-hooks-conditions-set
Open

sarankumar1325 wants to merge 1 commit into
nrwl:masterfrom
sarankumar1325:fix/register-hooks-conditions-set

Conversation

@sarankumar1325

Copy link
Copy Markdown
Contributor

Current Behavior

On Node 22.18, any nx command in a workspace that loads a local TypeScript plugin from source fails with conditions.has is not a function. Inside nx run it shows up as the misleading Could not find runner configuration for default.

ensureResolveConditionsInjected registers a module.registerHooks() resolve hook that appends the tsconfig conditions (e.g. development) and always passes an array to nextResolve. Node 22.18's CJS resolver hands the hook a Set (SafeSet) and calls .has() on what it gets back. Newer Node (22.21, 26) passes an array and rejects a Set, which is why it only breaks on some 22.x versions.

Expected Behavior

The hook keeps whatever container Node passed in: an array stays an array, and a Set-like value gets a Set back. The merge is in a small exported mergeResolveConditions helper with unit tests in register.spec.ts. Node's SafeSet is not instanceof Set, so the check is Array.isArray.

I checked the hook with a package that has a development export condition: require() resolves to the development entry on Node 22.18.0, 22.21.0 and 26.12.1. Before the change, 22.18.0 throws conditions.has is not a function.

This PR doesn't change getRunner swallowing the original error (the second point in the issue).

I used an AI assistant while working on this and reviewed the change myself.

Related Issue(s)

Fixes #37502

@sarankumar1325
sarankumar1325 requested a review from a team as a code owner October 23, 2026 14:26
@sarankumar1325
sarankumar1325 requested a review from lourw October 23, 2026 14:26
@netlify

netlify Bot commented Oct 23, 2026

Copy link
Copy Markdown

👷 Deploy request for nx-docs pending review.

Visit the deploys page to approve it

Name Link
🔨 Latest commit db28fd4

@netlify

netlify Bot commented Oct 23, 2026

Copy link
Copy Markdown

👷 Deploy request for nx-dev pending review.

Visit the deploys page to approve it

Name Link
🔨 Latest commit db28fd4

@chatgpt-codex-connector

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 🔄 Running since 2026-10-23T14:26:24.134431Z db28fd4 PR opened
ℹ️ 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.

This branch has not been deployed

No deployments
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.

Could not find runner configuration for default on Node 22.18.0: real error is conditions.has is not a function, swallowed by a bare catch in getRunner

1 participant