Bug 1406610 - No HTTP details for requests executed before the Console is activated; r=nchevobbe draft
authorJan Odvarko <odvarko@gmail.com>
Mon, 30 Oct 2017 15:32:15 +0100
changeset 688712 e8621a653e948af51f101a6731e64e01e66429e5
parent 688663 1c618b1a13662de7cec429f606367db3827b6dc7
child 688713 4e8477e77ba8ef6b469b3acd13d96b86113165d3
push id86828
push userjodvarko@mozilla.com
push dateMon, 30 Oct 2017 15:05:12 +0000
reviewersnchevobbe
bugs1406610
milestone58.0a1
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,
             });
           });
         }