Timeout without error
This commit is contained in:
parent
200df03007
commit
557dbb019a
10
index.js
10
index.js
|
@ -77,13 +77,17 @@ export default function pTimeout(promise, options) {
|
|||
return;
|
||||
}
|
||||
|
||||
const errorMessage = typeof message === 'string' ? message : `Promise timed out after ${milliseconds} milliseconds`;
|
||||
const timeoutError = message instanceof Error ? message : new TimeoutError(errorMessage);
|
||||
|
||||
if (typeof promise.cancel === 'function') {
|
||||
promise.cancel();
|
||||
}
|
||||
|
||||
if (message === false) {
|
||||
resolve();
|
||||
}
|
||||
|
||||
const errorMessage = typeof message === 'string' ? message : `Promise timed out after ${milliseconds} milliseconds`;
|
||||
const timeoutError = message instanceof Error ? message : new TimeoutError(errorMessage);
|
||||
|
||||
reject(timeoutError);
|
||||
}, milliseconds);
|
||||
|
||||
|
|
Loading…
Reference in New Issue