Bug 1130084 - Avoid spurious connection errors even on success. r=past
authorJ. Ryan Stinnett <jryans@gmail.com>
Thu, 19 Mar 2015 12:58:19 -0500
changeset 263263 a244a42cfa0c0d434a59f954deb83c486dc02b07
parent 263262 1dbf52164ffeeba315c79d4073441d3022a5e31f
child 263264 80ade5ec1d31bb79c27103149b0c446a365e5a49
push id4718
push userraliiev@mozilla.com
push dateMon, 11 May 2015 18:39:53 +0000
treeherdermozilla-beta@c20c4ef55f08 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerspast
bugs1130084
milestone39.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 1130084 - Avoid spurious connection errors even on success. r=past
browser/devtools/webide/modules/runtimes.js
toolkit/devtools/client/connection-manager.js
--- a/browser/devtools/webide/modules/runtimes.js
+++ b/browser/devtools/webide/modules/runtimes.js
@@ -448,16 +448,20 @@ WiFiRuntime.prototype = {
   type: RuntimeTypes.WIFI,
   connect: function(connection) {
     let service = discovery.getRemoteService("devtools", this.deviceName);
     if (!service) {
       return promise.reject(new Error("Can't find device: " + this.name));
     }
     connection.advertisement = service;
     connection.authenticator.sendOOB = this.sendOOB;
+    // Disable the default connection timeout, since QR scanning can take an
+    // unknown amount of time.  This prevents spurious errors (even after
+    // eventual success) from being shown.
+    connection.timeoutDelay = 0;
     connection.connect();
     return promise.resolve();
   },
   get id() {
     return this.deviceName;
   },
   get name() {
     return this.deviceName;
--- a/toolkit/devtools/client/connection-manager.js
+++ b/toolkit/devtools/client/connection-manager.js
@@ -12,16 +12,18 @@ const EventEmitter = require("devtools/t
 const DevToolsUtils = require("devtools/toolkit/DevToolsUtils");
 
 Cu.import("resource://gre/modules/Services.jsm");
 Cu.import("resource://gre/modules/devtools/dbg-client.jsm");
 Cu.import("resource://gre/modules/devtools/dbg-server.jsm");
 DevToolsUtils.defineLazyModuleGetter(this, "Task",
   "resource://gre/modules/Task.jsm");
 
+const REMOTE_TIMEOUT = "devtools.debugger.remote-timeout";
+
 /**
  * Connection Manager.
  *
  * To use this module:
  * const {ConnectionManager} = require("devtools/client/connection-manager");
  *
  * # ConnectionManager
  *
@@ -47,16 +49,18 @@ DevToolsUtils.defineLazyModuleGetter(thi
  *  . disconnect()          Disconnect if connected. Expect a "disconnecting" event
  *
  * Properties:
  *  . host                  IP address or hostname
  *  . port                  Port
  *  . logs                  Current logs. "newlog" event notifies new available logs
  *  . store                 Reference to a local data store (see below)
  *  . keepConnecting        Should the connection keep trying to connect?
+ *  . timeoutDelay          When should we give up (in ms)?
+ *                          0 means wait forever.
  *  . encryption            Should the connection be encrypted?
  *  . authentication        What authentication scheme should be used?
  *  . authenticator         The |Authenticator| instance used.  Overriding
  *                          properties of this instance may be useful to
  *                          customize authentication UX for a specific use case.
  *  . advertisement         The server's advertisement if found by discovery
  *  . status                Connection status:
  *                            Connection.Status.CONNECTED
@@ -228,18 +232,21 @@ Connection.prototype = {
       host: this.host,
       port: this.port,
       encryption: this.encryption,
       authenticator: this.authenticator
     });
     return settings;
   },
 
+  timeoutDelay: Services.prefs.getIntPref(REMOTE_TIMEOUT),
+
   resetOptions() {
     this.keepConnecting = false;
+    this.timeoutDelay = Services.prefs.getIntPref(REMOTE_TIMEOUT);
     this.encryption = false;
     this.authentication = null;
     this.advertisement = null;
   },
 
   disconnect: function(force) {
     if (this.status == Connection.Status.DESTROYED) {
       return;
@@ -263,18 +270,19 @@ Connection.prototype = {
       this._customTransport = transport;
       if (this._customTransport) {
         this.log("connecting (custom transport)");
       } else {
         this.log("connecting to " + this.host + ":" + this.port);
       }
       this._setStatus(Connection.Status.CONNECTING);
 
-      let delay = Services.prefs.getIntPref("devtools.debugger.remote-timeout");
-      this._timeoutID = setTimeout(this._onTimeout, delay);
+      if (this.timeoutDelay > 0) {
+        this._timeoutID = setTimeout(this._onTimeout, this.timeoutDelay);
+      }
       this._clientConnect();
     } else {
       let msg = "Can't connect. Client is not fully disconnected";
       this.log(msg);
       throw new Error(msg);
     }
   },