Skip to content

fix(ext/node): expose internal/net as requireable module - #34152

Merged
littledivy merged 1 commit into
mainfrom
divybot/issue-115-internal-net
May 17, 2026
Merged

littledivy merged 1 commit into
mainfrom
divybot/issue-115-internal-net

Conversation

@divybot

@divybot divybot commented May 17, 2026

Copy link
Copy Markdown
Contributor

Summary

Several Node.js test cases rely on require('internal/net') to reach the
internal symbols (kReinitializeHandle, kSetNoDelay, kSetKeepAlive,
kSetKeepAliveInitialDelay, etc.). Before this change the require threw
Cannot find module 'internal/net', because the module was loaded as a
script for internal use but never registered in the require() resolver.

The module itself is already implemented and used by node:net,
node:dns, internal/blocklist, etc. — this PR exposes it under the
internal/ path Node tests use directly and shares the kSet* symbols
between internal/net and net.ts.

Changes

  • ext/node/polyfills/01_require.js: bind the existing
    core.loadExtScript("ext:deno_node/internal/net.ts") result and add
    "internal/net": internalNet to nativeModuleExports.
  • ext/node/polyfills/internal/net.ts: add kSetNoDelay,
    kSetKeepAlive, and kSetKeepAliveInitialDelay symbols (previously
    defined privately in net.ts) so they share identity reachable from
    require('internal/net').
  • ext/node/polyfills/net.ts: consume the symbols from internal/net.ts
    instead of redefining them, propagate keepAlive/noDelay options
    from Socket.prototype.connect to setKeepAlive/setNoDelay (matches
    Node), and record the requested state in kSet* symbols even when the
    underlying handle does not expose native setNoDelay/setKeepAlive
    (so socket state reflects user intent regardless of native support).
  • tests/node_compat/config.jsonc: enable the two newly-passing tests.

Affected tests

Tests that previously failed with Cannot find module 'internal/net'
and now pass:

  • `parallel/test-tls-reinitialize-listeners.js`
  • `parallel/test-tls-connect-keepalive-nodelay.js`

Closes denoland/orchid#115

Note: supersedes #34143, which had a stale title from a previous
orchid run on the same orch/issue-115 branch and was being
contested by automated reverts.

Test plan

  • `cargo build --bin deno -p deno`
  • `./tools/format.js --js`
  • `cargo test --test node_compat test-tls-reinitialize-listeners` — passes
  • `cargo test --test node_compat test-tls-connect-keepalive-nodelay` — passes
  • `cargo test --test node_compat test-net-persistent-nodelay` — still passes (no regression)
  • `cargo test --test node_compat test-tls-net-socket-keepalive` — still passes (no regression)

Several Node tests rely on `require('internal/net')` to reach the
internal symbols `kReinitializeHandle`, `kSetNoDelay`, `kSetKeepAlive`,
and `kSetKeepAliveInitialDelay`. Before this change the require threw
`Cannot find module 'internal/net'` because the module was loaded as a
script for internal use but never registered in the `require()`
resolver.

Changes:
- `ext/node/polyfills/01_require.js`: Bind the existing
  `core.loadExtScript("ext:deno_node/internal/net.ts")` result and add
  `"internal/net": internalNet` to `nativeModuleExports`.
- `ext/node/polyfills/internal/net.ts`: Add `kSetNoDelay`, `kSetKeepAlive`,
  and `kSetKeepAliveInitialDelay` symbols (previously defined locally in
  `net.ts`) so they share identity with consumers via `internal/net`.
- `ext/node/polyfills/net.ts`: Consume the symbols from `internal/net.ts`
  instead of redefining them, propagate `keepAlive`/`noDelay` options
  from `Socket.prototype.connect` to `setKeepAlive`/`setNoDelay` (matches
  Node's behavior), and record the requested state in `kSet*` symbols even
  when the underlying handle does not expose native `setNoDelay`/
  `setKeepAlive` so user intent is reflected on the socket.

Affected tests (previously failing with `Cannot find module 'internal/net'`,
now pass):
- `parallel/test-tls-reinitialize-listeners.js`
- `parallel/test-tls-connect-keepalive-nodelay.js`

Closes denoland/orchid#115

Co-Authored-By: Divy Srivastava <[email protected]>
@littledivy
littledivy merged commit eb042fb into main May 17, 2026
183 of 215 checks passed
@littledivy
littledivy deleted the divybot/issue-115-internal-net branch May 17, 2026 05:56
littledivy added a commit to crowlKats/deno that referenced this pull request Jun 10, 2026
)

## Summary

Several Node.js test cases rely on `require('internal/net')` to reach
the
internal symbols (`kReinitializeHandle`, `kSetNoDelay`, `kSetKeepAlive`,
`kSetKeepAliveInitialDelay`, etc.). Before this change the require threw
`Cannot find module 'internal/net'`, because the module was loaded as a
script for internal use but never registered in the `require()`
resolver.

The module itself is already implemented and used by `node:net`,
`node:dns`, `internal/blocklist`, etc. — this PR exposes it under the
`internal/` path Node tests use directly and shares the `kSet*` symbols
between `internal/net` and `net.ts`.

## Changes

- `ext/node/polyfills/01_require.js`: bind the existing
  `core.loadExtScript("ext:deno_node/internal/net.ts")` result and add
  `"internal/net": internalNet` to `nativeModuleExports`.
- `ext/node/polyfills/internal/net.ts`: add `kSetNoDelay`,
  `kSetKeepAlive`, and `kSetKeepAliveInitialDelay` symbols (previously
  defined privately in `net.ts`) so they share identity reachable from
  `require('internal/net')`.
- `ext/node/polyfills/net.ts`: consume the symbols from
`internal/net.ts`
  instead of redefining them, propagate `keepAlive`/`noDelay` options
from `Socket.prototype.connect` to `setKeepAlive`/`setNoDelay` (matches
  Node), and record the requested state in `kSet*` symbols even when the
  underlying handle does not expose native `setNoDelay`/`setKeepAlive`
  (so socket state reflects user intent regardless of native support).
- `tests/node_compat/config.jsonc`: enable the two newly-passing tests.

## Affected tests

Tests that previously failed with `Cannot find module 'internal/net'`
and now pass:

- \`parallel/test-tls-reinitialize-listeners.js\`
- \`parallel/test-tls-connect-keepalive-nodelay.js\`

Closes denoland/orchid#115

> Note: supersedes denoland#34143, which had a stale title from a previous
> orchid run on the same `orch/issue-115` branch and was being
> contested by automated reverts.

## Test plan

- [x] \`cargo build --bin deno -p deno\`
- [x] \`./tools/format.js --js\`
- [x] \`cargo test --test node_compat test-tls-reinitialize-listeners\`
— passes
- [x] \`cargo test --test node_compat
test-tls-connect-keepalive-nodelay\` — passes
- [x] \`cargo test --test node_compat test-net-persistent-nodelay\` —
still passes (no regression)
- [x] \`cargo test --test node_compat test-tls-net-socket-keepalive\` —
still passes (no regression)

Co-authored-by: divybot <[email protected]>
Co-authored-by: Divy Srivastava <[email protected]>
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.

2 participants