If we remove the await from this test. the Error: socket hang up error get called.
request.on('error', (error: ConnectionError) => {
// this log two errors: "ConnectionRefusedError: connect ECONNREFUSED ::1 4444" and then "Error: socket hang up"
console.log(error);
errorPromise.resolve(error)
})
If we remove the
await
from this test. theError: socket hang up
error get called.as a workaround, I added
setTimeout(.., 5)
.