Skip to content

Wrapping existing net.Socket does not work #37873

Open
@marco-a

Description

  • Version: 14.16.0
  • Platform: MacOS
  • Subsystem: macOS Catalina 10.15.7

What steps will reproduce the bug?

const net = require("net")

const srv = net.createServer()

srv.on("connection", c => {
    const sock = new net.Socket({
        fd: c._handle.fd
    })
})

srv.listen(4444)

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

No required condition (as far as I can tell).

What is the expected behavior?

That a new net.Socket instance is created which behaves exactly like the original instance (c in this case).

What do you see instead?

An error is thrown (EEXISTS):

net.js:337
        throw errnoException(err, 'open');
        ^

Error: open EEXIST
    at new Socket (net.js:337:15)
    at Server.<anonymous> (test.js:6:15)
    at Server.emit (events.js:315:20)
    at TCP.onconnection (net.js:1560:8) {
  errno: -17,
  code: 'EEXIST',
  syscall: 'open'
}

Additional information

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    docIssues and PRs related to the documentations.netIssues and PRs related to the net subsystem.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions