Skip to content
This repository was archived by the owner on Jul 9, 2025. It is now read-only.

Commit b7646d1

Browse files
committed
Bug 1838555 - [devtools] Ignore requests with NS_BINDING_ABORTED, since they emmited from the cache r=devtools-reviewers,ochameau
Differential Revision: https://phabricator.services.mozilla.com/D181036
1 parent 5a74fbc commit b7646d1

File tree

4 files changed

+34
-5
lines changed

4 files changed

+34
-5
lines changed

devtools/client/netmonitor/test/browser_net_cached-status.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,23 @@ add_task(async function () {
9090
},
9191
];
9292

93+
// Cancel the 200 cached request, so that the test can also assert
94+
// that the NS_BINDING_ABORTED status is never displayed for cached requests.
95+
const observer = {
96+
QueryInterface: ChromeUtils.generateQI(["nsIObserver"]),
97+
observe(subject, topic, data) {
98+
subject = subject.QueryInterface(Ci.nsIHttpChannel);
99+
if (subject.URI.spec == STATUS_CODES_SJS + "?sts=ok&cached") {
100+
subject.cancel(Cr.NS_BINDING_ABORTED);
101+
Services.obs.removeObserver(
102+
observer,
103+
"http-on-examine-cached-response"
104+
);
105+
}
106+
},
107+
};
108+
Services.obs.addObserver(observer, "http-on-examine-cached-response");
109+
93110
info("Performing requests #1...");
94111
await performRequestsAndWait();
95112

devtools/shared/network-observer/NetworkObserver.sys.mjs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,7 @@ export class NetworkObserver {
335335
} else {
336336
// Handles any early blockings e.g by Web Extensions or by CORS
337337
const { blockingExtension, blockedReason } =
338-
lazy.NetworkUtils.getBlockedReason(channel);
338+
lazy.NetworkUtils.getBlockedReason(channel, httpActivity.fromCache);
339339
this.#createNetworkEvent(subject, { blockedReason, blockingExtension });
340340
}
341341
}
@@ -440,7 +440,10 @@ export class NetworkObserver {
440440
serverTimings
441441
);
442442
} else if (topic === "http-on-failed-opening-request") {
443-
const { blockedReason } = lazy.NetworkUtils.getBlockedReason(channel);
443+
const { blockedReason } = lazy.NetworkUtils.getBlockedReason(
444+
channel,
445+
httpActivity.fromCache
446+
);
444447
this.#createNetworkEvent(channel, { blockedReason });
445448
}
446449

devtools/shared/network-observer/NetworkResponseListener.sys.mjs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -532,7 +532,10 @@ export class NetworkResponseListener {
532532
// Check any errors or blocking scenarios which happen late in the cycle
533533
// e.g If a host is not found (NS_ERROR_UNKNOWN_HOST) or CORS blocking.
534534
const { blockingExtension, blockedReason } =
535-
lazy.NetworkUtils.getBlockedReason(this.#httpActivity.channel);
535+
lazy.NetworkUtils.getBlockedReason(
536+
this.#httpActivity.channel,
537+
this.#httpActivity.fromCache
538+
);
536539

537540
this.#httpActivity.owner.addResponseContent(response, {
538541
discardResponseBody: this.#httpActivity.discardResponseBody,

devtools/shared/network-observer/NetworkUtils.sys.mjs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -605,7 +605,7 @@ function legacyMatchRequest(channel, filters) {
605605
return false;
606606
}
607607

608-
function getBlockedReason(channel) {
608+
function getBlockedReason(channel, fromCache = false) {
609609
let blockingExtension, blockedReason;
610610
const { status } = channel;
611611

@@ -627,7 +627,7 @@ function getBlockedReason(channel) {
627627
// usually the requests (with these errors) might be displayed with various
628628
// other status codes.
629629
const ignoreList = [
630-
// This is emited when the request is already in the cache.
630+
// These are emited when the request is already in the cache.
631631
"NS_ERROR_PARSED_DATA_CACHED",
632632
// This is emited when there is some issues around images e.g When the img.src
633633
// links to a non existent url. This is typically shown as a 404 request.
@@ -638,6 +638,12 @@ function getBlockedReason(channel) {
638638
"NS_ERROR_ABORT",
639639
];
640640

641+
// NS_BINDING_ABORTED are emmited when request are abruptly halted, these are valid and should not be ignored.
642+
// They can also be emmited for requests already cache which have the `cached` status, these should be ignored.
643+
if (fromCache) {
644+
ignoreList.push("NS_BINDING_ABORTED");
645+
}
646+
641647
// If the request has not failed or is not blocked by a web extension, check for
642648
// any errors not on the ignore list. e.g When a host is not found (NS_ERROR_UNKNOWN_HOST).
643649
if (

0 commit comments

Comments
 (0)