This commit is contained in:
gheljenor 2017-11-19 09:28:08 +00:00 committed by GitHub
commit 4e4cb6008c
1 changed files with 4 additions and 0 deletions

View File

@ -22,6 +22,10 @@ module.exports = (promise, ms, fallback) => new Promise((resolve, reject) => {
const message = typeof fallback === 'string' ? fallback : `Promise timed out after ${ms} milliseconds`;
const err = fallback instanceof Error ? fallback : new TimeoutError(message);
if (typeof promise.cancel === 'function') {
promise.cancel(err);
}
reject(err);
}, ms);