fix: requestInterception should play nicely with canceled redirects (#1758)

Since interception events and `loadingFailed` events come from
different processes and are not serialized, we might get `loadingFailed` event and a subsequent outdated `requestIntercepted`.

Short-term, this patch stops assuming that interception events are
aligned with `loadingFailed`.

Long-term, this will be resolved as @caseq completes network
servicification effort in chromium.

Fixes #880.
This commit is contained in:
Andrey Lushnikov 2018-01-09 22:59:21 -08:00 committed by GitHub
parent f6b7c13316
commit 9634d13be2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -151,9 +151,10 @@ class NetworkManager extends EventEmitter {
if (event.redirectUrl) { if (event.redirectUrl) {
const request = this._interceptionIdToRequest.get(event.interceptionId); const request = this._interceptionIdToRequest.get(event.interceptionId);
console.assert(request, 'INTERNAL ERROR: failed to find request for interception redirect.'); if (request) {
this._handleRequestRedirect(request, event.responseStatusCode, event.responseHeaders); this._handleRequestRedirect(request, event.responseStatusCode, event.responseHeaders);
this._handleRequestStart(request._requestId, event.interceptionId, event.redirectUrl, event.resourceType, event.request, event.frameId); this._handleRequestStart(request._requestId, event.interceptionId, event.redirectUrl, event.resourceType, event.request, event.frameId);
}
return; return;
} }
const requestHash = generateRequestHash(event.request); const requestHash = generateRequestHash(event.request);