Bug 1406610 - No HTTP details for requests executed before the Console is activated; r=nchevobbe
MozReview-Commit-ID: B77VqNxXDWo
--- 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,
});
});
}