Skip to content

net: Create socket and immediately destroy throws AssertionError #2250

@feross

Description

@feross

Starting in v2.3.2, this code which used to work, started to throw an AssertionError:

var net = require('net')

var socket = net.connect(5000, '1.1.1.1') // nothing listening on this address
socket.on('error', function (err) {
  console.log('caught error' + err.message)
})
socket.destroy()

With the following exception:

assert.js:89
  throw new assert.AssertionError({
        ^
AssertionError: false == true
    at connect (net.js:778:10)
    at net.js:930:7
    at doNTCallback0 (node.js:408:9)
    at process._tickCallback (node.js:337:13)
    at Function.Module.runMain (module.js:473:11)
    at startup (node.js:117:18)
    at node.js:948:3

I traced the issue back to this PR by @evanlucas, reviewed by @trevnorris and @cjihrig: #2054

Metadata

Metadata

Assignees

No one assigned

    Labels

    confirmed-bugIssues with confirmed bugs.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