I need to reflect the promise of this function so that I always get a resolved promise, even if the underlying result of the promise was rejected, because I need to check dependency services' status upon server lift. If the dependency service is running well - return true
, otherwise return false
but do not reject/fail the promise, thus the whole process.
I've tried these two ways:
const logServerPromise = new Bluebird((resolve, reject) => {
return ping.promise.probe(logServerHost)
.then((result) => {
return resolve(result);
})
.catch((err) => {
return reject(err);
});
});
logServerPromise.reflect();
and
Bluebird.promisifyAll(ping.promise);
ping.promise.probeAsync().reflect();
In the first case it works well when the dependency is running, but when it's not - I get an exception with the usual error when it's not running, instead of the promise being handled by reflect()
.
In the second case it hangs no matter the status of the dependency.
Any idea how I can wrap/handle this?
Aucun commentaire:
Enregistrer un commentaire