diff --git a/packages/puppeteer-core/src/common/CallbackRegistry.ts b/packages/puppeteer-core/src/common/CallbackRegistry.ts index ea9f3d5abb5..6b8379177ba 100644 --- a/packages/puppeteer-core/src/common/CallbackRegistry.ts +++ b/packages/puppeteer-core/src/common/CallbackRegistry.ts @@ -31,17 +31,14 @@ export class CallbackRegistry { } catch (error) { // We still throw sync errors synchronously and clean up the scheduled // callback. - callback.promise - .valueOrThrow() - .catch(debugError) - .finally(() => { - this.#callbacks.delete(callback.id); - }); + callback.promise.catch(debugError).finally(() => { + this.#callbacks.delete(callback.id); + }); callback.reject(error as Error); throw error; } // Must only have sync code up until here. - return callback.promise.valueOrThrow().finally(() => { + return callback.promise.finally(() => { this.#callbacks.delete(callback.id); }); } @@ -148,8 +145,8 @@ export class Callback { return this.#id; } - get promise(): Deferred { - return this.#deferred; + get promise(): Promise { + return this.#deferred.valueOrThrow(); } get error(): ProtocolError {