We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 2be3698 commit 238b10aCopy full SHA for 238b10a
1 file changed
src/utils/runtime.ts
@@ -98,14 +98,11 @@ export async function measureTcpLatency(
98
} = {},
99
): Promise<number> {
100
const { host, port } = resolveTcpTarget(input);
101
- const latencies: number[] = [];
102
-
103
- for (let i = 0; i < attempts; i++) {
104
- const latency = await measureTcpConnectOnce(host, port, timeout);
105
- if (Number.isFinite(latency)) {
106
- latencies.push(latency);
107
- }
108
+ const promises = Array.from({ length: attempts }, () =>
+ measureTcpConnectOnce(host, port, timeout),
+ );
+ const results = await Promise.all(promises);
+ const latencies = results.filter(Number.isFinite);
109
110
if (latencies.length === 0) {
111
return Number.POSITIVE_INFINITY;
0 commit comments