mirror of
https://github.com/puppeteer/puppeteer
synced 2024-06-14 14:02:48 +00:00
fix: better debugging for WaitTask (#11330)
This commit is contained in:
parent
2da4915e6b
commit
d2480b022d
@ -48,6 +48,7 @@ export class WaitTask<T = unknown> {
|
|||||||
#args: unknown[];
|
#args: unknown[];
|
||||||
|
|
||||||
#timeout?: NodeJS.Timeout;
|
#timeout?: NodeJS.Timeout;
|
||||||
|
#timeoutError?: TimeoutError;
|
||||||
|
|
||||||
#result = Deferred.create<HandleFor<T>>();
|
#result = Deferred.create<HandleFor<T>>();
|
||||||
|
|
||||||
@ -88,10 +89,11 @@ export class WaitTask<T = unknown> {
|
|||||||
this.#world.taskManager.add(this);
|
this.#world.taskManager.add(this);
|
||||||
|
|
||||||
if (options.timeout) {
|
if (options.timeout) {
|
||||||
|
this.#timeoutError = new TimeoutError(
|
||||||
|
`Waiting failed: ${options.timeout}ms exceeded`
|
||||||
|
);
|
||||||
this.#timeout = setTimeout(() => {
|
this.#timeout = setTimeout(() => {
|
||||||
void this.terminate(
|
void this.terminate(this.#timeoutError);
|
||||||
new TimeoutError(`Waiting failed: ${options.timeout}ms exceeded`)
|
|
||||||
);
|
|
||||||
}, options.timeout);
|
}, options.timeout);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -184,9 +186,7 @@ export class WaitTask<T = unknown> {
|
|||||||
async terminate(error?: Error): Promise<void> {
|
async terminate(error?: Error): Promise<void> {
|
||||||
this.#world.taskManager.delete(this);
|
this.#world.taskManager.delete(this);
|
||||||
|
|
||||||
if (this.#timeout) {
|
clearTimeout(this.#timeout);
|
||||||
clearTimeout(this.#timeout);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (error && !this.#result.finished()) {
|
if (error && !this.#result.finished()) {
|
||||||
this.#result.reject(error);
|
this.#result.reject(error);
|
||||||
|
Loading…
Reference in New Issue
Block a user