Skip to content

socket.write callback error argument is undefined #44290

@prettydiff

Description

@prettydiff

Version

18.6.0

Platform

Microsoft Windows NT 10.0.19044.0 x64

Subsystem

none

What steps will reproduce the bug?

  1. Create a new socket using the net library.
import { Socket } from "net";
import { connect } from "tls";
const socket:Socket = connect({
    host: config.ip,
    port: config.port,
    rejectUnauthorized: false
})
  1. Write to the socket and provide a callback.
socket.write("hello", "utf8", function (writeError) {
    console.log(writeError);
});

It does not appear the writeError argument on the callback is populating correctly. By default the value should be null if no error messaging is passed or of type NodeJS.ErrnoException if an error is passed. Instead I am getting undefined.

I don't mind writing the solution and submitting a pull request, but I need some guidance. I believe the write method is defined at https://github.com/nodejs/node/blob/main/lib/net.js#L875-L914 but I cannot see any execution or definition of the callback there. The problem could also be lower in the streams library or higher in the tls library, so I am not sure how to get started debugging and writing a solution. I suspect its just a missing feature.

How often does it reproduce? Is there a required condition?

100% reproducible. No special conditions required.

What is the expected behavior?

Callback argument value is populated as either null or an object of type NodeJS.ErrnoException.

What do you see instead?

undefined.

Additional information

No response

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