diff --git a/packages/puppeteer-core/src/common/LifecycleWatcher.ts b/packages/puppeteer-core/src/common/LifecycleWatcher.ts index b68e22dc..fef7bfc1 100644 --- a/packages/puppeteer-core/src/common/LifecycleWatcher.ts +++ b/packages/puppeteer-core/src/common/LifecycleWatcher.ts @@ -168,6 +168,11 @@ export class LifecycleWatcher { NetworkManagerEmittedEvents.Response, this.#onResponse.bind(this) ), + addEventListener( + this.#frameManager.networkManager, + NetworkManagerEmittedEvents.RequestFailed, + this.#onRequestFailed.bind(this) + ), ]; this.#timeoutPromise = this.#createTimeoutPromise(); @@ -189,6 +194,13 @@ export class LifecycleWatcher { } } + #onRequestFailed(request: HTTPRequest): void { + if (this.#navigationRequest?._requestId !== request._requestId) { + return; + } + this.#navigationResponseReceived?.resolve(); + } + #onResponse(response: HTTPResponse): void { if (this.#navigationRequest?._requestId !== response.request()._requestId) { return;