Repository navigation
fix(ext/node): expose internal/net as requireable module - #34152
Merged
Merged
Conversation
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
approved these changes
May 17, 2026
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]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Several Node.js test cases rely on
require('internal/net')to reach theinternal symbols (
kReinitializeHandle,kSetNoDelay,kSetKeepAlive,kSetKeepAliveInitialDelay, etc.). Before this change the require threwCannot find module 'internal/net', because the module was loaded as ascript 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 theinternal/path Node tests use directly and shares thekSet*symbolsbetween
internal/netandnet.ts.Changes
ext/node/polyfills/01_require.js: bind the existingcore.loadExtScript("ext:deno_node/internal/net.ts")result and add"internal/net": internalNettonativeModuleExports.ext/node/polyfills/internal/net.ts: addkSetNoDelay,kSetKeepAlive, andkSetKeepAliveInitialDelaysymbols (previouslydefined privately in
net.ts) so they share identity reachable fromrequire('internal/net').ext/node/polyfills/net.ts: consume the symbols frominternal/net.tsinstead of redefining them, propagate
keepAlive/noDelayoptionsfrom
Socket.prototype.connecttosetKeepAlive/setNoDelay(matchesNode), and record the requested state in
kSet*symbols even when theunderlying 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:
Closes denoland/orchid#115
Test plan