Bug 1544976 Part 2 - Add devtools.debugger.quiet quiet pref to suppress warnings from protocol errors, r=loganfsmyth.
☠☠ backed out by 53014805c60b ☠ ☠
authorBrian Hackett <bhackett1024@gmail.com>
Thu, 25 Apr 2019 14:21:26 -1000
changeset 471849 30b551b1a2122b0c4478b3eeb790a96204d4cfcf
parent 471848 1ebc89e3ad9757e2c921ff78670637b7147e0037
child 471850 a7ff9b445c9c131ec5d51d3686090bd67a24d815
push id35936
push usershindli@mozilla.com
push dateTue, 30 Apr 2019 03:48:37 +0000
treeherdermozilla-central@da2b564f6df0 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersloganfsmyth
bugs1544976
milestone68.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 1544976 Part 2 - Add devtools.debugger.quiet quiet pref to suppress warnings from protocol errors, r=loganfsmyth. Differential Revision: https://phabricator.services.mozilla.com/D28933
devtools/shared/ThreadSafeDevToolsUtils.js
devtools/shared/flags.js
devtools/shared/fronts/targets/target-mixin.js
devtools/shared/preferences/devtools-shared.js
--- a/devtools/shared/ThreadSafeDevToolsUtils.js
+++ b/devtools/shared/ThreadSafeDevToolsUtils.js
@@ -4,16 +4,18 @@
 
 "use strict";
 
 /**
  * General utilities used throughout devtools that can also be used in
  * workers.
  */
 
+var flags = require("./flags");
+
 /**
  * Immutably reduce the given `...objs` into one object. The reduction is
  * applied from left to right, so `immutableUpdate({ a: 1 }, { a: 2 })` will
  * result in `{ a: 2 }`. The resulting object is frozen.
  *
  * Example usage:
  *
  *     const original = { foo: 1, bar: 2, baz: 3 };
@@ -107,17 +109,19 @@ exports.makeInfallible = function(handle
   return function() {
     try {
       return handler.apply(this, arguments);
     } catch (ex) {
       let who = "Handler function";
       if (name) {
         who += " " + name;
       }
-      exports.reportException(who, ex);
+      if (!flags.quiet) {
+        exports.reportException(who, ex);
+      }
       return undefined;
     }
   };
 };
 
 /**
  * Turn the |error| into a string, without fail.
  *
--- a/devtools/shared/flags.js
+++ b/devtools/shared/flags.js
@@ -53,13 +53,20 @@ makePrefTrackedFlag(exports, "wantLoggin
 /**
  * Setting the "devtools.debugger.log.verbose" preference to true will enable a
  * more verbose logging of the the RDP. The "devtools.debugger.log" preference
  * must be set to true as well for this to have any effect.
  */
 makePrefTrackedFlag(exports, "wantVerbose", "devtools.debugger.log.verbose");
 
 /**
+ * Setting the "devtools.debugger.quiet" preference to true will turn off
+ * logging for protocol errors that were caught and handled. These errors can
+ * happen in normal operation when threads shut down.
+ */
+makePrefTrackedFlag(exports, "quiet", "devtools.debugger.quiet");
+
+/**
  * Setting the "devtools.testing" preference to true will toggle on certain
  * behaviors that can differ from the production version of the code. These
  * behaviors typically enable easier testing or enhanced debugging features.
  */
 makePrefTrackedFlag(exports, "testing", "devtools.testing");
--- a/devtools/shared/fronts/targets/target-mixin.js
+++ b/devtools/shared/fronts/targets/target-mixin.js
@@ -7,16 +7,18 @@
 // We are requiring a module from client whereas this module is from shared.
 // This shouldn't happen, but Fronts should rather be part of client anyway.
 // Otherwise gDevTools is only used for local tabs and should propably only
 // used by a subclass, specific to local tabs.
 loader.lazyRequireGetter(this, "gDevTools", "devtools/client/framework/devtools", true);
 loader.lazyRequireGetter(this, "TargetFactory", "devtools/client/framework/target", true);
 loader.lazyRequireGetter(this, "getFront", "devtools/shared/protocol", true);
 
+const flags = require("../../flags");
+
 /**
  * A Target represents a debuggable context. It can be a browser tab, a tab on
  * a remote device, like a tab on Firefox for Android. But it can also be an add-on,
  * as well as firefox parent process, or just one of its content process.
  * A Target is related to a given TargetActor, for which we derive this class.
  *
  * Providing a generalized abstraction of a web-page or web-browser (available
  * either locally or remotely) is beyond the scope of this class (and maybe
@@ -546,25 +548,29 @@ function TargetMixin(parentClass) {
         } else if (this.detach && this.actorID) {
           // The client was handed to us, so we are not responsible for closing
           // it. We just need to detach from the tab, if already attached.
           // |detach| may fail if the connection is already dead, so proceed with
           // cleanup directly after this.
           try {
             await this.detach();
           } catch (e) {
-            console.warn(`Error while detaching target: ${e.message}`);
+            if (!flags.quiet) {
+              console.warn(`Error while detaching target: ${e.message}`);
+            }
           }
         }
 
         if (this.threadClient) {
           try {
             await this.threadClient.detach();
           } catch (e) {
-            console.warn(`Error while detaching the thread front: ${e.message}`);
+            if (!flags.quiet) {
+              console.warn(`Error while detaching the thread front: ${e.message}`);
+            }
           }
         }
 
         // Do that very last in order to let a chance to dispatch `detach` requests.
         super.destroy();
 
         this._cleanup();
       })();
--- a/devtools/shared/preferences/devtools-shared.js
+++ b/devtools/shared/preferences/devtools-shared.js
@@ -27,16 +27,17 @@ pref("devtools.debugger.remote-enabled",
 // In local builds, enable the browser toolbox by default
 pref("devtools.chrome.enabled", true, sticky);
 pref("devtools.debugger.remote-enabled", true, sticky);
 #endif
 
 // Disable remote debugging protocol logging
 pref("devtools.debugger.log", false);
 pref("devtools.debugger.log.verbose", false);
+pref("devtools.debugger.quiet", false);
 
 pref("devtools.debugger.remote-port", 6000);
 pref("devtools.debugger.remote-websocket", false);
 // Force debugger server binding on the loopback interface
 pref("devtools.debugger.force-local", true);
 
 // Limit for intercepted request and response bodies (1 MB)
 // Possible values: