force timeout, logs indicate that pings are getting stuck (#12251)

* force timeout, logs indicate that pings are getting stuck

(cherry picked from commit ff6a71819be272253d969a0be681dc9749a0f00d)

* actually reject the promise

(cherry picked from commit fe1ca5d399)
This commit is contained in:
Spencer 2017-06-12 12:45:06 -07:00 committed by spalger
parent 7d590505d2
commit 2d8565540f

View file

@ -3,7 +3,12 @@ import { fromNode as fcb } from 'bluebird';
export async function ping(url) {
try {
await fcb(cb => request({ url, timeout: 1000 }, cb));
await Promise.race([
fcb(cb => request(url, cb)),
new Promise((resolve, reject) => {
setTimeout(() => reject(new Error('timeout')), 1000);
})
]);
return true;
} catch (err) {
return false;