Skip to content

Commit

Permalink
fix: resolve navigation requests when request fails
Browse files Browse the repository at this point in the history
  • Loading branch information
OrKoN authored and jrandolf committed Oct 28, 2022
1 parent 2d2120c commit 7c5bf0e
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions packages/puppeteer-core/src/common/LifecycleWatcher.ts
Expand Up @@ -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();
Expand All @@ -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;
Expand Down

0 comments on commit 7c5bf0e

Please sign in to comment.