Skip to content

Commit

Permalink
Request: fix aborted navigations
Browse files Browse the repository at this point in the history
  • Loading branch information
chrmod committed Nov 22, 2024
1 parent 8a75628 commit a1a1c93
Show file tree
Hide file tree
Showing 2 changed files with 132 additions and 54 deletions.
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
24 changes: 24 additions & 0 deletions reporting/src/request/page-store.js
Original file line number Diff line number Diff line change
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 Down Expand Up @@ -234,6 +240,24 @@ export default class PageStore {
this.#pages.set(tabId, nextPage);
};

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

if (frameId !== 0) {
return;
}

// navigation aborted most likely due to redirect
// revert to previous page as soon a new navigation will start
if (error === 'Error code 2152398850') {
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

0 comments on commit a1a1c93

Please sign in to comment.