Skip to content

node:net: Socket and Server methods read as non-callable values #3397

Closed

Description

@andrewtdiz

Summary

node:net Socket and Server instances should expose function-valued methods when user code reads method properties. Perry can route some direct method calls, but method-value reads currently return numeric/native handles or otherwise non-callable values, so feature detection and aliased method calls do not match Node.

Node Behavior

test-files/test_parity_net.ts constructs new net.Server() and new net.Socket() and probes method property values without opening a live network connection:

const s = new net.Server();
console.log("server.address() before listen:", s.address());
console.log("server.close typeof:", typeof s.close);
console.log("server.getConnections typeof:", typeof s.getConnections);
console.log("server.listen typeof:", typeof s.listen);
console.log("server.ref typeof:", typeof s.ref);
console.log("server.unref typeof:", typeof s.unref);

const sock = new net.Socket();
console.log("socket.address typeof:", typeof sock.address);
console.log("socket.connect typeof:", typeof sock.connect);
console.log("socket.destroy typeof:", typeof sock.destroy);
console.log("socket.end typeof:", typeof sock.end);
console.log("socket.write typeof:", typeof sock.write);

Node output from ./run_parity_tests.sh --filter test_parity_net includes:

server.address() before listen: null
server.close typeof: function
server.getConnections typeof: function
server.listen typeof: function
server.ref typeof: function
server.unref typeof: function
socket.address typeof: function
socket.connect typeof: function
socket.destroy typeof: function
socket.destroySoon typeof: function
socket.end typeof: function
socket.pause typeof: function
socket.ref typeof: function
socket.resetAndDestroy typeof: function
socket.resume typeof: function
socket.setEncoding typeof: function
socket.setKeepAlive typeof: function
socket.setNoDelay typeof: function
socket.setTimeout typeof: function
socket.unref typeof: function
socket.write typeof: function

Perry Behavior

The same run shows non-callable values for these object methods:

class net.Server typeof: function
new net.Server typeof: object
Server error: address is not a function
class net.Socket typeof: function
new net.Socket typeof: object
socket.address typeof: number
socket.connect typeof: number
socket.destroy typeof: number
socket.destroySoon typeof: number
socket.end typeof: number
socket.pause typeof: number
socket.ref typeof: number
socket.resetAndDestroy typeof: number
socket.resume typeof: number
socket.setEncoding typeof: number
socket.setKeepAlive typeof: number
socket.setNoDelay typeof: number
socket.setTimeout typeof: number
socket.unref typeof: number
socket.write typeof: number

The focused net validation node-suite currently passes 4/4, so this is not about invalid input validation. The other broad test_parity_net mismatches map to existing leaves for BlockList / SocketAddress, server connection-count/limit state, socket TOS methods, and socket metadata/counter properties.

Suggested PR Cut

Batch this with related issues in:
node:net: Socket and Server object surface parity cut

Good batch candidates:

Do not batch with:

Acceptance

  • parity/regression test proves reading net.Server and net.Socket methods returns callable functions for covered methods
  • aliased calls such as const write = socket.write; either behave like Node for covered cases or fail with Node-compatible receiver errors when called incorrectly
  • existing direct-call socket/server behavior and net validation fixtures remain passing
  • related known-failure/docs/manifest entries updated if touched

Duplicate checks

Searched issues/PRs for:

  • net.Socket method values typeof number function address connect destroy write
  • node:net Socket method-value reads non-callable number function
  • native method-value reads typeof number function net.Socket
  • method-value reads typeof function number native method
  • value is not a function native method reads typeof number
  • PR search net.Socket method values typeof number function address connect destroy write

I found existing open net leaves for class data structures, Server connection-limit state, socket TOS methods, socket state/address/counter properties, Stream alias, IPv6 zone IDs, and auto-select-family validation, but no open precise issue for Socket / Server method property reads returning non-callable values.

Activity

  1. andrewtdiz commented on May 31, 2026

    @andrewtdiz
    ContributorAuthor

    I’m taking this one in a focused PR cut for net Socket/Server method-value reads. Scope: make covered Server and Socket method property reads callable and add parity coverage for direct method reads/aliased values without broad live socket behavior changes.

  2. andrewtdiz commented on May 31, 2026

    @andrewtdiz
    ContributorAuthor

    Opened PR: #3519

    Verification:

    • Pre-fix PATH=/home/github-runner/actions-runner/externals/node24/bin:$PATH ./run_parity_tests.sh --suite node-suite --module net failed 1/6 at the new method-value fixture.
    • Post-rebase PATH=/home/github-runner/actions-runner/externals/node24/bin:$PATH ./run_parity_tests.sh --suite node-suite --module net passed 6/6.
    • Full cargo check for affected/runtime packages passed with existing warnings.
    • cargo fmt --all -- --check, ./scripts/check_file_size.sh, jq empty test-parity/known_failures.json, and git diff --check HEAD~1..HEAD all passed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions