fix: resolve navigation requests when request fails (#9178)
#8768 fixes flakiness in handling navigations but it didn't account for the fact that subsequent navigation requests could be aborted via the request interception. In that case, the navigationResponseReceived promise would never be resolved. This PR adds a listener for the failed network requests and resolves the promise if the network request has failed. Adding test coverage for this seems tricky, as the reproduction depends on timing of the second navigation request. Closes #9175
This commit is contained in:
parent
2d2120cea1
commit
c11297baa5
@ -168,6 +168,11 @@ export class LifecycleWatcher {
|
|||||||
NetworkManagerEmittedEvents.Response,
|
NetworkManagerEmittedEvents.Response,
|
||||||
this.#onResponse.bind(this)
|
this.#onResponse.bind(this)
|
||||||
),
|
),
|
||||||
|
addEventListener(
|
||||||
|
this.#frameManager.networkManager,
|
||||||
|
NetworkManagerEmittedEvents.RequestFailed,
|
||||||
|
this.#onRequestFailed.bind(this)
|
||||||
|
),
|
||||||
];
|
];
|
||||||
|
|
||||||
this.#timeoutPromise = this.#createTimeoutPromise();
|
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 {
|
#onResponse(response: HTTPResponse): void {
|
||||||
if (this.#navigationRequest?._requestId !== response.request()._requestId) {
|
if (this.#navigationRequest?._requestId !== response.request()._requestId) {
|
||||||
return;
|
return;
|
||||||
|
Loading…
Reference in New Issue
Block a user