Skip to content

A net.Socket given to an 'upgrade' listener cannot be written to: socket.write returns undefined #10342

Closed as duplicate

Description

@proggeramlug

A net.Socket handed to an 'upgrade' listener cannot be written to: socket.write(...) returns undefined and nothing reaches the wire.

The 'upgrade' event itself is correct — it fires, and its arguments (request, socket, head) are right. Only writing back is broken, which makes the event useless for its main purpose: completing a WebSocket or CONNECT handshake by hand.

Cause

The listener receives the socket as an untyped value, so socket.write(...) goes through the composite handle dispatch rather than being statically resolved. net's socket_method_name table has no write row — the method is normally reached through the statically resolved js_ext_net_socket_write3, which a typed receiver picks. With no row, the dynamic path finds nothing and returns undefined instead of throwing, so the failure is silent.

Scope

Reproduced on both transports: the hyper/tokio path on the base commit and the turnloop path. This is pre-existing and not a turnloop regression — found while validating the P5 lane (docs/turnloop/p5-report.md).

Fix shape

Add the missing write row (and audit the rest of that table against the statically resolved entry points — a silent undefined from a missing row is the kind of gap that hides until someone uses the dynamic receiver).

Activity

  1. TheHypnoo commented on Sep 28, 2026

    @TheHypnoo
    Member

    Closing as a duplicate of #10470, which describes the same symptom (socket.write is undefined in an 'upgrade' listener) together with its root cause: Perry completes the WebSocket handshake itself and passes an internal id instead of a net.Socket. The raw-socket half is tracked in #10471.

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