fix(chromium): abort fetch requests that lack networkId (#2254)

These requests are usually internal ones, and we can safely abort them.
An example would be DevTools loading cached resources to show the content.
There will never be a matching Network.requestWillBeSent event, so we do not
report them to the user.
This commit is contained in:
Dmitry Gozman 2020-05-15 15:22:29 -07:00 committed by GitHub
parent 99b7aaace8
commit 4bf5742d47
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 18 additions and 3 deletions

View File

@ -140,7 +140,17 @@ export class CRNetworkManager {
requestId: event.requestId
}).catch(logError(this._page));
}
if (!event.networkId || event.request.url.startsWith('data:'))
if (!event.networkId) {
// Fetch without networkId means that request was not recongnized by inspector, and
// it will never receive Network.requestWillBeSent. Most likely, this is an internal request
// that we can safely fail.
this._client.send('Fetch.failRequest', {
requestId: event.requestId,
errorReason: 'Aborted',
}).catch(logError(this._page));
return;
}
if (event.request.url.startsWith('data:'))
return;
const requestId = event.networkId;

View File

@ -215,8 +215,13 @@ export class FrameManager {
this._inflightRequestStarted(request);
for (const task of request.frame()._frameTasks)
task.onRequest(request);
if (!request._isFavicon)
this._page._requestStarted(request);
if (request._isFavicon) {
const route = request._route();
if (route)
route.continue();
return;
}
this._page._requestStarted(request);
}
requestReceivedResponse(response: network.Response) {