Skip to content

node:net: expose Socket state, address, and byte-counter properties #2549

Closed

Description

@andrewtdiz

Summary

Node's net.Socket exposes a sizeable property surface for connection state, endpoint metadata, and byte counters. Perry currently implements core socket methods and socket.address(), but the committed net.Socket path does not expose the corresponding properties.

Missing/unwired examples from the current parity inventory include:

  • socket.autoSelectFamilyAttemptedAddresses
  • socket.bufferSize
  • socket.bytesRead
  • socket.bytesWritten
  • socket.connecting
  • socket.destroyed
  • socket.localAddress, socket.localPort, socket.localFamily
  • socket.pending
  • socket.remoteAddress, socket.remotePort, socket.remoteFamily
  • socket.readyState
  • socket.timeout

Evidence

  • Current Node docs list these properties under net.Socket: https://nodejs.org/api/net.html#class-netsocket
  • docs/runtime-parity.md:879-893 lists the socket metadata/counter/state property rows.
  • docs/runtime-parity-gaps.md:1163-1170 still retains the same property set in the node:net gap list.
  • test-files/test_parity_net.ts:114-128 only probes these properties on a newly allocated net.Socket.
  • crates/perry-ext-net/src/lib.rs:231-244 defines SocketState with cmd_tx, pending_rx, is_open, local_addr, and raw bridge state, but no byte counters, remote address cache, timeout value, ready-state enum, or auto-select attempted address list.
  • crates/perry-ext-net/src/lib.rs:671-684 and :1197-1205 allocate SocketState without those fields.
  • crates/perry-codegen/src/lower_call/native_table/net_events.rs:253-419 wires methods such as write, end, destroy, option setters, and socket.address(), but has no getter rows for the socket properties above.
  • crates/perry-api-manifest/src/entries.rs:547-590 likewise registers socket methods only; no property getter entries exist for these metadata/counter/state properties.

Expected behavior

A Node-compatible socket should expose stable property reads before, during, and after connection lifecycle transitions. For example:

const net = require('node:net');
const socket = new net.Socket();

console.log(socket.pending);       // true before connect
console.log(socket.connecting);    // false before connect
console.log(socket.destroyed);     // false before destroy
console.log(socket.bytesRead);     // 0 initially
console.log(socket.bytesWritten);  // 0 initially
console.log(socket.readyState);    // Node-shaped state string
console.log(socket.timeout);       // timeout value or undefined

After connection, local* and remote* properties should reflect the socket endpoints, byte counters should update with reads/writes, readyState/pending/connecting/destroyed should track lifecycle transitions, and autoSelectFamilyAttemptedAddresses should report Happy Eyeballs attempts when relevant.

Duplicate check

I searched issues and PRs for net.Socket remoteAddress bytesRead readyState socket properties, net.Socket bytesRead bytesWritten remoteAddress, and related socket metadata terms. Existing closed net lifecycle issues (#1852/#2131) covered connection hangs, socket.address(), EventEmitter wiring, and callback ordering. Open #2522 covers module-level auto-select-family defaults, and #2548 covers TOS methods. I did not find an open tracker for this net.Socket property surface.

I could not run a fresh local Perry reproduction in this checkout because no built perry binary is present; this is based on committed source, parity metadata, current Node docs, and issue/PR search.

Activity

  1. andrewtdiz commented on May 30, 2026

    @andrewtdiz
    ContributorAuthor

    Related object-surface leaf: #3397 covers net.Socket method property reads returning non-callable numeric/native values instead of functions. It is a same-PR candidate if the socket metadata/counter work is already touching Socket property dispatch, but should remain separate from endpoint state/counter semantics.

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