I have 2 systems using Nodejs 16.19.0 - one on my local Windows 11 and another in a GKE pod running a Ubuntu 20 container. In both systems, I open an interactive Nodejs prompt and run the following, pointing to some IP address that I know will NOT reply and cause a timeout on the client side:
$ node # open interactive nodejs prompt and run the following at once:
console.log(new Date());
req=http.request('http://x.x.x.x');
req.on('error', ()=>{}); // just to cleanup the output
req.on('close', () => { console.log('close ' + new Date()); });
I print the start and end dates to see how long it takes the client to close with the timeout.
In my local system, it takes ~20 seconds. In the other system, it takes 130 seconds. I didn't configure anything special in my Node. Why is there a difference?
Also, the consequence of this, is that when I also add a "timeout" handler for, say, 30 seconds, it will NOT fire on Windows and WILL fire in the pod...