getPort() returned Promise never fullfils if range is given
ibc opened this issue · comments
Iñaki Baz Castillo commented
const pickPort = require('pick-port');
async function run()
{
let port;
port = await pickPort({ type: 'tcp', range: { min: 5000, max: 5001 }, reserveTimeout: 100 });
console.info('picked TCP port: %d', port);
port = await pickPort({ type: 'tcp', range: { min: 5000, max: 5001 }, reserveTimeout: 100 });
console.info('picked TCP port: %d', port);
port = await pickPort({ type: 'tcp', range: { min: 5000, max: 5001 }, reserveTimeout: 100 });
console.info('picked TCP port: %d', port);
port = await pickPort({ type: 'tcp', range: { min: 5000, max: 5001 }, reserveTimeout: 100 });
console.info('picked TCP port: %d', port);
}
run();
Output:
picked TCP port: 5001
picked TCP port: 5000
(nothing else)
If I add a .catch((error) => ...
in any pickPort()
call then I get the proper "All ports in the given range are in use" error. However, it should also throw an error in the code above (instead, the code is suspended).