Skip to content

fix(ext/node): fix 8 Node.js compat test failures#32755

Merged
bartlomieju merged 6 commits intomainfrom
fix/node-compat-tests
Mar 18, 2026
Merged

fix(ext/node): fix 8 Node.js compat test failures#32755
bartlomieju merged 6 commits intomainfrom
fix/node-compat-tests

Conversation

@bartlomieju
Copy link
Copy Markdown
Member

Summary

Fixes 8 Node.js compat tests that were failing after the node_test submodule update to Node.js 25.8.1 (#32705). Closes part of #32706.

  • events: listenerCount() now handles EventTarget instances by delegating to getEventListeners()
  • worker_threads: cpuUsage() accepts NaN/null/undefined as "no previous value" (matching Node.js behavior)
  • process: add quic: false to process.features
  • util: parseEnv() returns a null-prototype object
  • net: fix autoSelectFamilyAttemptTimeout default from 250 to 500 (matching Node.js)
  • streams: pass readableType/type options through Duplex.toWeb() to create byte streams for BYOB readers
  • fs: handle ENOTDIR in globSync getDirentSync() instead of throwing

Enabled tests

  • test-child-process-spawn-timeout-kill-signal.js
  • test-child-process-fork-timeout-kill-signal.js
  • test-worker-cpu-usage.js
  • test-process-features.js
  • test-util-parse-env.js
  • test-net-autoselectfamily-attempt-timeout-default-value.js
  • test-stream-duplex.js
  • test-fs-glob.mjs

Test plan

  • All 8 newly enabled tests pass via ./x test-compat
  • CI passes

🤖 Generated with Claude Code

bartlomieju and others added 4 commits March 15, 2026 16:57
- events: handle EventTarget in listenerCount() via getEventListeners
- worker_threads: accept NaN/null/undefined in cpuUsage() prevValue
- process: add quic field to process.features
- util: return null-prototype object from parseEnv()
- net: fix autoSelectFamilyAttemptTimeout default from 250 to 500

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Pass readableType/type options through Duplex.toWeb() to
newReadableWritablePairFromDuplex() and into the underlying
ReadableStream, enabling BYOB readers on byte streams.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- streams: pass readableType/type options through Duplex.toWeb() to
  create byte streams for BYOB readers
- fs: handle ENOTDIR in globSync getDirentSync instead of throwing

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@bartlomieju bartlomieju changed the title fix(node): fix 8 Node.js compat test failures fix(ext/node): fix 8 Node.js compat test failures Mar 15, 2026
Copy link
Copy Markdown
Contributor

@kajukitli kajukitli left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The PR contains a logical error in the type validation for prevValue. The NumberIsNaN() check is semantically incorrect when applied to an object - it will always return false for objects since NaN is a numeric concept. The check is redundant and misleading, as the subsequent validateObject call handles the actual type validation.

[HIGH] ext/node/polyfills/worker_threads.ts:665: Incorrect type check: NumberIsNaN(prevValue) always returns false for objects. This check is semantically wrong since prevValue is expected to be an object with user and system properties, not a number. The condition !NumberIsNaN(prevValue) is always true for any object, making it redundant and confusing.

Suggestion: Simplify the condition to just prevValue != null and remove the NumberIsNaN check, since validateObject on line 666 already handles the actual type validation.

bartlomieju and others added 2 commits March 16, 2026 13:29
NumberIsNaN() always returns false for objects, making the check
misleading. Simplify to just `prevValue != null` since validateObject
handles actual type validation.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
The NumberIsNaN check is intentional — Node.js treats NaN as "no
previous value" (like null/undefined), so it must be filtered out
before reaching validateObject.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

let autoSelectFamilyDefault = true;
let autoSelectFamilyAttemptTimeoutDefault = 250;
let autoSelectFamilyAttemptTimeoutDefault = 500;
Copy link
Copy Markdown
Contributor

@Tango992 Tango992 Mar 16, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

isn't 250 already the correct value here? (CMIIW)
Ref: https://github.com/nodejs/node/pull/52474/changes

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The current Node.js default is actually 500, not 250. See node_options.h: uint64_t network_family_autoselection_attempt_timeout = 500;. It was bumped from 250 to 500 after the PR you linked.

@bartlomieju bartlomieju merged commit 0fede96 into main Mar 18, 2026
112 checks passed
@bartlomieju bartlomieju deleted the fix/node-compat-tests branch March 18, 2026 08:39
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.

4 participants