Callback was already calleld with async.parallel function
<p>I am writing a simple port scanner using core <code>net</code> module from Node.js. I am getting a 'Callback was already called' error with my code. Can you spot please where the error is coming from? Below is my code:</p>

<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-js lang-js prettyprint-override"><code>const net = require('net')
const async = require('async')

function findPortStatus(host, port, timeout, cb) {

  const socket = new net.Socket()

  socket.setTimeout(timeout, () =&gt; {
    // couldn't establish a connection because of timeout
    socket.destroy()
    return cb(null, null)
  })

  socket.connect(port, host, () =&gt; {
    // connection established
    return cb(null, port)
  })

  socket.on('error', (err) =&gt; {
    // couldn't establish a connection
    return cb(null, null)
  })
}

const funcs = []

for (let port = 0; port &lt;= 80; port++) {
  funcs.push(function(callback) {
    findPortStatus('192.30.253.112', port, 4000, (err, port) =&gt; {
      if (!err) {
        return callback(null, port)
      }
    })
  })
}

async.parallel(funcs, (err, ports) =&gt; {
  if (err) {
    console.error(err.message)
  } else {
    for (let port of ports) {
      if (port) {
        console.log(port)
      }
    }
  }
})</code></pre>
</div>
</div>
</p>