Bug 1406610 - No HTTP details for requests executed before the Console is activated; r=nchevobbe
authorJan Odvarko <odvarko@gmail.com>
Mon, 30 Oct 2017 15:32:15 +0100
changeset 389017 bb0c71d42196c92af8a7d018dc1f53265c08ab25
parent 389016 e10c2f71fdccf1924911925c5b708df7338c0685
child 389018 7b41783886cc11f0becfece31a367ddc14d03771
push id32777
push userarchaeopteryx@coole-files.de
push dateMon, 30 Oct 2017 22:44:45 +0000
treeherdermozilla-central@dd0f265a1300 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersnchevobbe
bugs1406610
milestone58.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1406610 - No HTTP details for requests executed before the Console is activated; r=nchevobbe MozReview-Commit-ID: B77VqNxXDWo
devtools/client/webconsole/new-console-output/store.js
--- a/devtools/client/webconsole/new-console-output/store.js
+++ b/devtools/client/webconsole/new-console-output/store.js
@@ -25,16 +25,19 @@ const {
 } = require("devtools/client/webconsole/new-console-output/constants");
 const { reducers } = require("./reducers/index");
 const Services = require("Services");
 const {
   getMessage,
   getAllMessagesUiById,
 } = require("devtools/client/webconsole/new-console-output/selectors/messages");
 const DataProvider = require("devtools/client/netmonitor/src/connector/firefox-data-provider");
+const {
+  getAllNetworkMessagesUpdateById,
+} = require("devtools/client/webconsole/new-console-output/selectors/messages");
 
 /**
  * Create and configure store for the Console panel. This is the place
  * where various enhancers and middleware can be registered.
  */
 function configureStore(hud, options = {}) {
   const logLimit = options.logLimit
     || Math.max(Services.prefs.getIntPref("devtools.hud.loglimit"), 1);
@@ -182,16 +185,33 @@ function enableNetProvider(hud) {
       // If network message has been opened, fetch all HTTP details
       // from the backend. It can happen (especially in test) that
       // the message is opened before all network event updates are
       // received. The rest of updates will be handled below, see:
       // NETWORK_MESSAGE_UPDATE action handler.
       if (type == MESSAGE_OPEN) {
         let message = getMessage(state, action.id);
         if (!message.openedOnce && message.source == "network") {
+          let updates = getAllNetworkMessagesUpdateById(newState);
+
+          // If there is no network request update received for this
+          // request-log, it's likely that it comes from cache.
+          // I.e. it's been executed before the console panel started
+          // listening from network events. Let fix that by updating
+          // the reducer now.
+          // Executing the reducer means that the `networkMessagesUpdateById`
+          // is updated (a actor key created). The key is needed for proper
+          // handling NETWORK_UPDATE_REQUEST event (in the same reducer).
+          if (!updates[action.id]) {
+            newState = reducer(newState, {
+              type: NETWORK_MESSAGE_UPDATE,
+              message: message,
+            });
+          }
+
           dataProvider.onNetworkEvent(null, message);
           message.updates.forEach(updateType => {
             dataProvider.onNetworkEventUpdate(null, {
               packet: { updateType: updateType },
               networkInfo: message,
             });
           });
         }