mirror of
https://github.com/puppeteer/puppeteer
synced 2024-06-14 14:02:48 +00:00
refactor: don't expose the deferred (#12130)
This commit is contained in:
parent
22a680dd09
commit
35504ae0e7
@ -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<unknown> {
|
||||
return this.#deferred;
|
||||
get promise(): Promise<unknown> {
|
||||
return this.#deferred.valueOrThrow();
|
||||
}
|
||||
|
||||
get error(): ProtocolError {
|
||||
|
Loading…
Reference in New Issue
Block a user