Skip to content

Commit 4bf5742

Browse files
authored
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.
1 parent 99b7aaa commit 4bf5742

File tree

2 files changed

+18
-3
lines changed

2 files changed

+18
-3
lines changed

src/chromium/crNetworkManager.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,17 @@ export class CRNetworkManager {
140140
requestId: event.requestId
141141
}).catch(logError(this._page));
142142
}
143-
if (!event.networkId || event.request.url.startsWith('data:'))
143+
if (!event.networkId) {
144+
// Fetch without networkId means that request was not recongnized by inspector, and
145+
// it will never receive Network.requestWillBeSent. Most likely, this is an internal request
146+
// that we can safely fail.
147+
this._client.send('Fetch.failRequest', {
148+
requestId: event.requestId,
149+
errorReason: 'Aborted',
150+
}).catch(logError(this._page));
151+
return;
152+
}
153+
if (event.request.url.startsWith('data:'))
144154
return;
145155

146156
const requestId = event.networkId;

src/frames.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -215,8 +215,13 @@ export class FrameManager {
215215
this._inflightRequestStarted(request);
216216
for (const task of request.frame()._frameTasks)
217217
task.onRequest(request);
218-
if (!request._isFavicon)
219-
this._page._requestStarted(request);
218+
if (request._isFavicon) {
219+
const route = request._route();
220+
if (route)
221+
route.continue();
222+
return;
223+
}
224+
this._page._requestStarted(request);
220225
}
221226

222227
requestReceivedResponse(response: network.Response) {

0 commit comments

Comments
 (0)