Skip to content

Instantly share code, notes, and snippets.

@TooTallNate
Created February 11, 2020 19:43
Show Gist options
  • Save TooTallNate/7b540264334d967bbc233621692373ff to your computer and use it in GitHub Desktop.
Save TooTallNate/7b540264334d967bbc233621692373ff to your computer and use it in GitHub Desktop.
Does anyone know why this script takes >2s to receive the `error` event on Windows? On MacOS it's essentially instant…
$ time node slow-windows-error.js
Error: connect ECONNREFUSED 127.0.0.1:4
at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1134:16) {
errno: 'ECONNREFUSED',
code: 'ECONNREFUSED',
syscall: 'connect',
address: '127.0.0.1',
port: 4
}
real 0m0.093s
user 0m0.045s
sys 0m0.024s
$ time node slow-windows-error.js
Error: connect ECONNREFUSED 127.0.0.1:4
at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1129:14) {
errno: 'ECONNREFUSED',
code: 'ECONNREFUSED',
syscall: 'connect',
address: '127.0.0.1',
port: 4
}
real 0m2.345s
user 0m0.000s
sys 0m0.046s
const net = require('net');
net.connect({ host: '127.0.0.1', port: 4 }).on('error', console.error);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment