Bug 1420037 - Fix netmonitor "dataProvider is null" exception on DAMP. r=Honza draft
authorAlexandre Poirot <poirot.alex@gmail.com>
Thu, 23 Nov 2017 00:36:13 -0800
changeset 702483 6e46b1cec119b6b7ecc6b1fbd9be8c545cfcff0a
parent 701872 5378dcb45044a160fad93b02eed0c617f3324dbc
child 702484 a6a164f0b3a1f7431602fed305818643f24c98de
push id90526
push userbmo:poirot.alex@gmail.com
push dateThu, 23 Nov 2017 09:30:25 +0000
reviewersHonza
bugs1420037
milestone59.0a1
Bug 1420037 - Fix netmonitor "dataProvider is null" exception on DAMP. r=Honza MozReview-Commit-ID: EhCSSV0ZFrB
devtools/client/netmonitor/src/connector/firefox-connector.js
--- a/devtools/client/netmonitor/src/connector/firefox-connector.js
+++ b/devtools/client/netmonitor/src/connector/firefox-connector.js
@@ -78,16 +78,17 @@ class FirefoxConnector {
     this.removeListeners();
 
     this.tabTarget.off("will-navigate");
 
     this.tabTarget = null;
     this.webConsoleClient = null;
     this.timelineFront = null;
     this.dataProvider = null;
+    this.panel = null;
   }
 
   pause() {
     this.removeListeners();
   }
 
   resume() {
     this.addListeners();
@@ -124,21 +125,25 @@ class FirefoxConnector {
   }
 
   navigate() {
     if (this.dataProvider.isPayloadQueueEmpty()) {
       this.onReloaded();
       return;
     }
     let listener = () => {
-      if (!this.dataProvider.isPayloadQueueEmpty()) {
+      if (this.dataProvider && !this.dataProvider.isPayloadQueueEmpty()) {
         return;
       }
       window.off(EVENTS.PAYLOAD_READY, listener);
-      this.onReloaded();
+      // Netmonitor may already be destroyed,
+      // so do not try to notify the listeners
+      if (this.dataProvider) {
+        this.onReloaded();
+      }
     };
     window.on(EVENTS.PAYLOAD_READY, listener);
   }
 
   onReloaded() {
     this.panel.emit("reloaded");
   }