diff options
Diffstat (limited to '')
-rw-r--r-- | remote/test/puppeteer/src/util/DebuggableDeferredPromise.ts | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/remote/test/puppeteer/src/util/DebuggableDeferredPromise.ts b/remote/test/puppeteer/src/util/DebuggableDeferredPromise.ts new file mode 100644 index 0000000000..474743273c --- /dev/null +++ b/remote/test/puppeteer/src/util/DebuggableDeferredPromise.ts @@ -0,0 +1,20 @@ +import {DEFERRED_PROMISE_DEBUG_TIMEOUT} from '../environment.js'; +import {DeferredPromise, createDeferredPromise} from './DeferredPromise.js'; + +/** + * Creates and returns a deferred promise using DEFERRED_PROMISE_DEBUG_TIMEOUT + * if it's specified or a normal deferred promise otherwise. + * + * @internal + */ +export function createDebuggableDeferredPromise<T>( + message: string +): DeferredPromise<T> { + if (DEFERRED_PROMISE_DEBUG_TIMEOUT > 0) { + return createDeferredPromise({ + message, + timeout: DEFERRED_PROMISE_DEBUG_TIMEOUT, + }); + } + return createDeferredPromise(); +} |