Skip to content

fix(transform): handle Set and Array for conditions in esm sync loader#41316

Closed
SebTardif wants to merge 1 commit into
microsoft:mainfrom
SebTardif:fix-41311
Closed

fix(transform): handle Set and Array for conditions in esm sync loader#41316
SebTardif wants to merge 1 commit into
microsoft:mainfrom
SebTardif:fix-41311

Conversation

@SebTardif

Copy link
Copy Markdown
Contributor

Node registerHooks can pass `conditions` as a Set (not Array) in some
require-initiated sync paths on Node 22.15-22.16. The check added in #41138
used optional chaining `.includes` which does not exist on Set, causing
"conditions?.includes is not a function" during test loading.

Use a safe `has` / `includes` probe. Widen the type annotation.
Added regression test for the ESM resolve path.

Fixes #41311

Node registerHooks can pass \`conditions\` as a Set (not Array) in some
require-initiated sync paths on Node 22.15-22.16. The check added in microsoft#41138
used optional chaining \`.includes\` which does not exist on Set, causing
"conditions?.includes is not a function" during test loading (see microsoft#41311).

Use a safe \`has\` / \`includes\` probe. Widen the type annotation.
Added regression test for the ESM resolve path.

Fixes microsoft#41311

Signed-off-by: Sebastien Tardif <sebtardif@ncf.ca>
@dgozman

dgozman commented Jun 16, 2026

Copy link
Copy Markdown
Collaborator

Closing is favor of #41319.

@dgozman dgozman closed this Jun 16, 2026
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.

[Bug]: [Regression]: Sync loader throws "context.conditions?.includes is not a function" on Node 22.15

2 participants