Skip to content

Commit

Permalink
refactor: don't expose the deferred (#12130)
Browse files Browse the repository at this point in the history
  • Loading branch information
Lightning00Blade committed Mar 22, 2024
1 parent 22a680d commit 35504ae
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions packages/puppeteer-core/src/common/CallbackRegistry.ts
Expand Up @@ -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);
});
}
Expand Down Expand Up @@ -148,8 +145,8 @@ export class Callback {
return this.#id;
}

get promise(): Deferred<unknown> {
return this.#deferred;
get promise(): Promise<unknown> {
return this.#deferred.valueOrThrow();
}

get error(): ProtocolError {
Expand Down

0 comments on commit 35504ae

Please sign in to comment.