Bug 1391488 - catch and ignore errors fetching the hostname from the DNS service. r?kitcambridge draft
authorMark Hammond <mhammond@skippinet.com.au>
Fri, 01 Sep 2017 16:48:24 +1000
changeset 657193 fd49d4ae1a534dc10f30622b0245cd8e73b983c9
parent 656346 04b6be50a2526c7a26a63715f441c47e1aa1f9be
child 729376 053a8f21585d2c13c49dbceb7413c1abe9faba10
push id77468
push userbmo:markh@mozilla.com
push dateFri, 01 Sep 2017 06:50:12 +0000
reviewerskitcambridge
bugs1391488
milestone57.0a1
Bug 1391488 - catch and ignore errors fetching the hostname from the DNS service. r?kitcambridge MozReview-Commit-ID: 5hTDNmzTXdQ
services/sync/modules/util.js
--- a/services/sync/modules/util.js
+++ b/services/sync/modules/util.js
@@ -573,21 +573,29 @@ this.Utils = {
     if (user == "%USERNAME%" && env.get("USERNAME")) {
       user = env.get("USERNAME");
     }
 
     let brand = Services.strings.createBundle(
       "chrome://branding/locale/brand.properties");
     let brandName = brand.GetStringFromName("brandShortName");
 
+    // The DNS service may fail to provide a hostname in edge-cases we don't
+    // fully understand - bug 1391488.
+    let hostname;
+    try {
+      // hostname of the system, usually assigned by the user or admin
+      hostname = Cc["@mozilla.org/network/dns-service;1"].getService(Ci.nsIDNSService).myHostName;
+    } catch (ex) {
+      Cu.reportError(ex);
+    }
     let system =
       // 'device' is defined on unix systems
       Cc["@mozilla.org/system-info;1"].getService(Ci.nsIPropertyBag2).get("device") ||
-      // hostname of the system, usually assigned by the user or admin
-      Cc["@mozilla.org/network/dns-service;1"].getService(Ci.nsIDNSService).myHostName ||
+      hostname ||
       // fall back on ua info string
       Cc["@mozilla.org/network/protocol;1?name=http"].getService(Ci.nsIHttpProtocolHandler).oscpu;
 
     let syncStrings = Services.strings.createBundle("chrome://weave/locale/sync.properties");
     return syncStrings.formatStringFromName("client.name2", [user, brandName, system], 3);
   },
 
   getDeviceName() {