tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

commit ffc380878c697f68eb9be108a6ba15924f9b2d31
parent a29b71d7f6f034765a58d90fbeb3db8acfbed6ed
Author: Alexandre Poirot <poirot.alex@gmail.com>
Date:   Tue,  7 Oct 2025 22:22:11 +0000

Bug 1991698 - [devtools] Drop netmonitor actions as soon as the panel starts destroying. r=devtools-reviewers,nchevobbe

Differential Revision: https://phabricator.services.mozilla.com/D267188

Diffstat:
Mdevtools/client/netmonitor/src/app.js | 6++++++
Mdevtools/client/netmonitor/src/create-store.js | 18++++++++++++------
Mdevtools/client/netmonitor/test/browser_net_duration.js | 14++++++++++----
Mdevtools/client/netmonitor/test/new-resend-request/browser_net_resend.js | 2++
Mdevtools/server/connectors/js-process-actor/DevToolsProcessParent.sys.mjs | 2+-
5 files changed, 31 insertions(+), 11 deletions(-)

diff --git a/devtools/client/netmonitor/src/app.js b/devtools/client/netmonitor/src/app.js @@ -18,6 +18,9 @@ const ToolboxProvider = require("resource://devtools/client/framework/store-prov const { visibilityHandlerStore, } = require("resource://devtools/client/shared/redux/visibilityHandlerStore.js"); +const { + START_IGNORE_ACTION, +} = require("resource://devtools/client/shared/redux/middleware/ignore.js"); const FluentReact = require("resource://devtools/client/shared/vendor/fluent-react.js"); const App = require("resource://devtools/client/netmonitor/src/components/App.js"); @@ -116,6 +119,9 @@ NetMonitorApp.prototype = { // where the Network panel is initialized without the toolbox // and running in a tab (see initialize.js for details). this.api.destroy(); + + // Prevents any further action from being dispatched + this.api.store.dispatch(START_IGNORE_ACTION); }, /** diff --git a/devtools/client/netmonitor/src/create-store.js b/devtools/client/netmonitor/src/create-store.js @@ -10,20 +10,23 @@ const { } = require("resource://devtools/client/shared/vendor/redux.js"); const { - waitUntilService, -} = require("resource://devtools/client/shared/redux/middleware/wait-service.js"); - -const { MIN_COLUMN_WIDTH, DEFAULT_COLUMN_WIDTH, } = require("resource://devtools/client/netmonitor/src/constants.js"); // Middleware -const batching = require("resource://devtools/client/netmonitor/src/middleware/batching.js"); -const prefs = require("resource://devtools/client/netmonitor/src/middleware/prefs.js"); +const { + ignore, +} = require("resource://devtools/client/shared/redux/middleware/ignore.js"); const { thunk, } = require("resource://devtools/client/shared/redux/middleware/thunk.js"); +const { + waitUntilService, +} = require("resource://devtools/client/shared/redux/middleware/wait-service.js"); + +const batching = require("resource://devtools/client/netmonitor/src/middleware/batching.js"); +const prefs = require("resource://devtools/client/netmonitor/src/middleware/prefs.js"); const throttling = require("resource://devtools/client/netmonitor/src/middleware/throttling.js"); const eventTelemetry = require("resource://devtools/client/netmonitor/src/middleware/event-telemetry.js"); const requestBlocking = require("resource://devtools/client/netmonitor/src/middleware/request-blocking.js"); @@ -78,6 +81,9 @@ function configureStore(connector, commands, telemetry) { // Prepare middleware. const middleware = applyMiddleware( + // Register ignore first to prevent any subsequent middleware from running + ignore, + requestBlocking(commands), thunk({ connector, commands }), prefs, diff --git a/devtools/client/netmonitor/test/browser_net_duration.js b/devtools/client/netmonitor/test/browser_net_duration.js @@ -18,7 +18,8 @@ add_task(async function () { ); store.dispatch(Actions.batchEnable(false)); - let waitForPending = waitForNetworkEvents(monitor, 1, { + const waitForFullRequest = waitForNetworkEvents(monitor, 1); + const waitForPartialPending = waitForNetworkEvents(monitor, 1, { expectedPayloadReady: 0, expectedEventTimings: 0, }); @@ -29,17 +30,22 @@ add_task(async function () { method: "GET", }, ]); - await waitForPending; + // Wait for the first request to be partially retrieve + await waitForPartialPending; const pendingArr = getDurations(); - waitForPending = waitForNetworkEvents(monitor, 1); + const waitForRequest = waitForNetworkEvents(monitor, 1); performRequestsInContent([ { url: "sjs_long-polling-server.sjs?unblock", method: "GET", }, ]); - await waitForPending; + // Wait for the full retrieval of the second request + await waitForRequest; + // Also wait for full retrieval of the first request which has been unblocked by the second + await waitForFullRequest; + const resolvedArr = getDurations(); is(pendingArr[0], "", "Duration should be listed as '' until resolved."); diff --git a/devtools/client/netmonitor/test/new-resend-request/browser_net_resend.js b/devtools/client/netmonitor/test/new-resend-request/browser_net_resend.js @@ -156,8 +156,10 @@ async function resendRequestAndWaitForNewRequest(monitor, originalRequestItem) { info("Open the context menu and select the resend for the request"); EventUtils.sendMouseEvent({ type: "contextmenu" }, originalRequestItem); + const wait = waitForNetworkEvents(monitor, 1); await selectContextMenuItem(monitor, "request-list-context-resend-only"); await waitForNewRequest; + await wait; const newResourceId = getSelectedRequest(store.getState()).id; diff --git a/devtools/server/connectors/js-process-actor/DevToolsProcessParent.sys.mjs b/devtools/server/connectors/js-process-actor/DevToolsProcessParent.sys.mjs @@ -206,7 +206,7 @@ export class DevToolsProcessParent extends JSProcessActorParent { #onConnectionClosed = (status, prefix) => { for (const watcherInfo of this.#watchers.values()) { - if (watcherInfo.watcher.conn.prefix == prefix) { + if (watcherInfo.watcher.conn?.prefix == prefix) { this.#unregisterWatcher(watcherInfo.watcher); } }