Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Request: fix aborted navigations #141

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
162 changes: 108 additions & 54 deletions reporting/snapshots/0004/snapshot.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@
"t": -1730735663859,
"tps": {
"a-v2.sndcdn.com": {
"c": 32,
"content_length": 444706,
"resp_ob": 32,
"scheme_https": 32,
"status_200": 32,
"type_2": 16,
"type_3": 15,
"c": 35,
"content_length": 447390,
"resp_ob": 35,
"scheme_https": 35,
"status_200": 35,
"type_2": 18,
"type_3": 16,
"type_4": 1
},
"accounts.google.com": {
Expand Down Expand Up @@ -55,32 +55,51 @@
"type_3": 2
},
"cf-hls-media.sndcdn.com": {
"c": 27,
"content_length": 3202255,
"has_qs": 27,
"resp_ob": 27,
"scheme_https": 27,
"status_200": 27,
"type_11": 27
"c": 37,
"content_length": 3842022,
"has_qs": 37,
"resp_ob": 37,
"scheme_https": 37,
"status_200": 37,
"type_11": 37
},
"d2g5n8b622dsn7.cloudfront.net": {
"c": 1,
"content_length": 1,
"resp_ob": 1,
"scheme_https": 1,
"status_404": 1,
"type_11": 1
},
"events.statsigapi.net": {
"c": 2,
"content_length": 17,
"has_post": 1,
"resp_ob": 2,
"scheme_https": 2,
"status_200": 1,
"status_202": 1,
"type_11": 2
},
"featuregates.org": {
"c": 6,
"has_post": 3,
"scheme_https": 6,
"type_11": 6
"c": 8,
"has_post": 4,
"scheme_https": 8,
"type_11": 8
},
"geolocation.onetrust.com": {
"c": 1,
"scheme_https": 1,
"type_11": 1
},
"i1.sndcdn.com": {
"c": 13,
"content_length": 186264,
"resp_ob": 13,
"scheme_https": 13,
"status_200": 13,
"type_3": 13
"c": 307,
"content_length": 826774,
"resp_ob": 307,
"scheme_https": 307,
"status_200": 307,
"type_11": 2,
"type_3": 305
},
"ingest.us.sentry.io": {
"c": 1,
Expand Down Expand Up @@ -118,9 +137,9 @@
"type_11": 1
},
"sb.scorecardresearch.com": {
"c": 1,
"scheme_https": 1,
"type_2": 1
"c": 4,
"scheme_https": 4,
"type_2": 4
},
"secure.quantserve.com": {
"c": 1,
Expand Down Expand Up @@ -165,6 +184,14 @@
"scheme_https": 1,
"type_2": 1
},
"wave.sndcdn.com": {
"c": 4,
"content_length": 4921,
"resp_ob": 4,
"scheme_https": 4,
"status_200": 4,
"type_11": 4
},
"www.googletagmanager.com": {
"c": 3,
"has_qs": 3,
Expand Down Expand Up @@ -205,13 +232,13 @@
"t": -1730735663859,
"tps": {
"a-v2.sndcdn.com": {
"c": 32,
"content_length": 444706,
"resp_ob": 32,
"scheme_https": 32,
"status_200": 32,
"type_2": 16,
"type_3": 15,
"c": 35,
"content_length": 447390,
"resp_ob": 35,
"scheme_https": 35,
"status_200": 35,
"type_2": 18,
"type_3": 16,
"type_4": 1
},
"assets.web.soundcloud.cloud": {
Expand Down Expand Up @@ -241,32 +268,51 @@
"type_3": 2
},
"cf-hls-media.sndcdn.com": {
"c": 27,
"content_length": 3202255,
"has_qs": 27,
"resp_ob": 27,
"scheme_https": 27,
"status_200": 27,
"type_11": 27
"c": 37,
"content_length": 3842022,
"has_qs": 37,
"resp_ob": 37,
"scheme_https": 37,
"status_200": 37,
"type_11": 37
},
"d2g5n8b622dsn7.cloudfront.net": {
"c": 1,
"content_length": 1,
"resp_ob": 1,
"scheme_https": 1,
"status_404": 1,
"type_11": 1
},
"events.statsigapi.net": {
"c": 2,
"content_length": 17,
"has_post": 1,
"resp_ob": 2,
"scheme_https": 2,
"status_200": 1,
"status_202": 1,
"type_11": 2
},
"featuregates.org": {
"c": 6,
"has_post": 3,
"scheme_https": 6,
"type_11": 6
"c": 8,
"has_post": 4,
"scheme_https": 8,
"type_11": 8
},
"geolocation.onetrust.com": {
"c": 1,
"scheme_https": 1,
"type_11": 1
},
"i1.sndcdn.com": {
"c": 13,
"content_length": 186264,
"resp_ob": 13,
"scheme_https": 13,
"status_200": 13,
"type_3": 13
"c": 307,
"content_length": 826774,
"resp_ob": 307,
"scheme_https": 307,
"status_200": 307,
"type_11": 2,
"type_3": 305
},
"ingest.us.sentry.io": {
"c": 1,
Expand Down Expand Up @@ -304,9 +350,9 @@
"type_11": 1
},
"sb.scorecardresearch.com": {
"c": 1,
"scheme_https": 1,
"type_2": 1
"c": 4,
"scheme_https": 4,
"type_2": 4
},
"secure.quantserve.com": {
"c": 1,
Expand Down Expand Up @@ -351,6 +397,14 @@
"scheme_https": 1,
"type_2": 1
},
"wave.sndcdn.com": {
"c": 4,
"content_length": 4921,
"resp_ob": 4,
"scheme_https": 4,
"status_200": 4,
"type_11": 4
},
"www.googletagmanager.com": {
"c": 3,
"has_qs": 3,
Expand Down
10 changes: 4 additions & 6 deletions reporting/snapshots/0006/snapshot.json
Original file line number Diff line number Diff line change
Expand Up @@ -950,15 +950,14 @@
},
"www.google.com": {
"c": 3,
"content_length": 46,
"content_length": 44,
"has_post": 1,
"has_qs": 3,
"referer_leak_path": 3,
"referer_leak_site": 3,
"resp_ob": 5,
"resp_ob": 3,
"scheme_https": 3,
"status_200": 2,
"status_204": 2,
"status_302": 1,
"type_19": 2,
"type_3": 1
Expand Down Expand Up @@ -1959,15 +1958,14 @@
},
"www.google.com": {
"c": 3,
"content_length": 46,
"content_length": 44,
"has_post": 1,
"has_qs": 3,
"referer_leak_path": 3,
"referer_leak_site": 3,
"resp_ob": 5,
"resp_ob": 3,
"scheme_https": 3,
"status_200": 2,
"status_204": 2,
"status_302": 1,
"type_19": 2,
"type_3": 1
Expand Down
40 changes: 39 additions & 1 deletion reporting/src/request/page-store.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0
*/

import logger from '../logger.js';
import ChromeStorageMap from './utils/chrome-storage-map.js';

const PAGE_TTL = 1000 * 60 * 60; // 1 hour
Expand Down Expand Up @@ -77,6 +77,9 @@ export default class PageStore {
chrome.webNavigation.onBeforeNavigate.addListener(this.#onBeforeNavigate);
chrome.webNavigation.onCommitted.addListener(this.#onNavigationCommitted);
chrome.webNavigation.onCompleted.addListener(this.#onNavigationCompleted);
chrome.webNavigation.onErrorOccurred.addListener(
this.#onNavigationErrorOccured,
);
chrome.windows.onFocusChanged?.addListener(this.#onWindowFocusChanged);

// popupate initially open tabs
Expand All @@ -103,6 +106,9 @@ export default class PageStore {
chrome.webNavigation.onCompleted.removeListener(
this.#onNavigationCompleted,
);
chrome.webNavigation.onErrorOccurred.removeListener(
this.#onNavigationErrorOccured,
);
chrome.windows.onFocusChanged?.removeListener(this.#onWindowFocusChanged);
}

Expand All @@ -112,6 +118,10 @@ export default class PageStore {
}

#stagePage(page) {
if (page.destroyed) {
logger.warn('[PageStore] trying to stage a page multipe times', page.url);
return;
}
makePageActive(page, false);
page.destroyed = Date.now();
// unset previous (to prevent history chain memory leak)
Expand Down Expand Up @@ -234,6 +244,34 @@ export default class PageStore {
this.#pages.set(tabId, nextPage);
};

#onNavigationErrorOccured = (details) => {
const { frameId, tabId, url, error } = details;

if (frameId !== 0 || !url.startsWith('http')) {
return;
}

/**
*
On Firefox some navigation can trigger following event sequence:

* onBeforeNavigate
* onErrorOccurred with "error":"Error code 2152398850"
* onBeforeNavigate
* onCommitted

That was causing an extra page object to be created which was messing up the previous page logic.
*/
// 2152398850 stands for NS_BINDING_ABORTED https://searchfox.org/mozilla-central/rev/6597dd03bad82c891d084eed25cafd0c85fb333e/tools/ts/config/error_list.json#48
if (error === 'Error code 2152398850') {
philipp-classen marked this conversation as resolved.
Show resolved Hide resolved
const page = this.#pages.get(tabId);

if (page && page.url === url) {
this.#pages.set(tabId, page.previous);
}
}
};

#onNavigationCommitted = (details) => {
const { frameId, tabId } = details;
const page = this.#pages.get(tabId);
Expand Down
Loading