puppeteer/packages/puppeteer-core/src/util/DebuggableDeferred.ts

20 lines
525 B
TypeScript
Raw Normal View History

import {DEFERRED_PROMISE_DEBUG_TIMEOUT} from '../environment.js';
2023-05-31 21:36:19 +00:00
import {Deferred} from './Deferred.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 createDebuggableDeferred<T>(message: string): Deferred<T> {
if (DEFERRED_PROMISE_DEBUG_TIMEOUT > 0) {
2023-05-31 21:36:19 +00:00
return Deferred.create({
message,
timeout: DEFERRED_PROMISE_DEBUG_TIMEOUT,
});
}
2023-05-31 21:36:19 +00:00
return Deferred.create();
}