pingman icon indicating copy to clipboard operation
pingman copied to clipboard

pings (promises) in parallel impacts other

Open kiranpradeep opened this issue 1 year ago • 0 comments

In below sample, both hosts 192.168.1.1 and 192.168.1.100 are reachable,

var ping = require('pingman');

async function test_pingman() {
    let pings = [];
    const hosts = ['192.168.1.1','192.168.1.100'];
    for (const host of hosts) {
        pings.push(ping(host));
    }

    const responses = await Promise.allSettled(pings);
    for(const response of responses) {
        console.log(response);
    }
}

test_pingman();

It appears results are getting mixed up.

Screenshot 2023-12-21 at 8 14 28 PM

kiranpradeep avatar Dec 21 '23 14:12 kiranpradeep