Skip to content
This repository was archived by the owner on Nov 21, 2019. It is now read-only.

Commit 3eb5d33

Browse files
author
icymind
committed
reduce ping timeout to 500ms by set a timeout
1 parent 8390cc7 commit 3eb5d33

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/renderer/lib/utils.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -400,7 +400,7 @@ class Utils {
400400

401401
static async isHostAlive (ip) {
402402
// vboxmanage list runningvms 在windows下非常不可靠
403-
return new Promise((resolve, reject) => {
403+
const p1 = new Promise((resolve, reject) => {
404404
ping.promise.probe(ip, {
405405
timeout: 1,
406406
min_reply: 1
@@ -409,6 +409,14 @@ class Utils {
409409
resolve(res.alive)
410410
})
411411
})
412+
413+
const p2 = new Promise((resolve, reject) => {
414+
setTimeout(() => {
415+
resolve(false)
416+
}, 500)
417+
})
418+
419+
return Promise.race([p1, p2])
412420
}
413421
}
414422

0 commit comments

Comments
 (0)