Skip to content
This repository was archived by the owner on Apr 22, 2023. It is now read-only.
This repository was archived by the owner on Apr 22, 2023. It is now read-only.

net: unref() is not persistent #7077

Closed
Closed
@bnoordhuis

Description

@bnoordhuis
var net = require('net');
var server = net.createServer();
server.unref();
server.listen();
net.connect(server.address().port).unref();

It hangs because of the unref() that comes before listen() and the one after connect(). In that vein:

require('net').connect(42).unref();

It fails with ECONNREFUSED because the unref() is a no-op. The expected behavior for both scripts is that they simply quit. Affects v0.10 and master.

The documentation doesn't mention when it's okay to call unref(). For the sake of user friendliness, net.Socket and net.Server should remember the ref state and retroactively apply it when the handle is created. Probably applies to other handle types as well.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions