bug 1492499: marionette: warn on TimedPromise bailing; r=automatedtester
authorAndreas Tolfsen <ato@sny.no>
Thu, 11 Oct 2018 16:40:36 +0000
changeset 443621 9ca2c179e63e292808918158eb778b16bf18e67f
parent 443620 0e4677eff22b0e4baa9968cd3b2be54cf2a668ab
child 443622 77e0c47e18d61653440632dbd6a699c1e6c07365
push id109420
push useraciure@mozilla.com
push dateWed, 31 Oct 2018 05:11:56 +0000
treeherdermozilla-inbound@b357da105c49 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersautomatedtester
bugs1492499
milestone65.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 1492499: marionette: warn on TimedPromise bailing; r=automatedtester We often use TimedPromise to ensure Marionette does not unexpectedly block on a promise that, for whatever reason, does not resolve. It can however be useful to be alerted when they don't, as it quite often means there is an underlying problem. Depends on D8406 Differential Revision: https://phabricator.services.mozilla.com/D8407
testing/marionette/sync.js
--- a/testing/marionette/sync.js
+++ b/testing/marionette/sync.js
@@ -4,21 +4,22 @@
 
 "use strict";
 
 ChromeUtils.import("resource://gre/modules/Services.jsm");
 ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
 
 const {
   error,
+  stack,
   TimeoutError,
 } = ChromeUtils.import("chrome://marionette/content/error.js", {});
 const {Log} = ChromeUtils.import("chrome://marionette/content/log.js", {});
 
-XPCOMUtils.defineLazyGetter(this, "logger", Log.get);
+XPCOMUtils.defineLazyGetter(this, "log", Log.get);
 
 this.EXPORTED_SYMBOLS = [
   "IdlePromise",
   "MessageManagerDestroyedPromise",
   "PollPromise",
   "Sleep",
   "TimedPromise",
 ];
@@ -180,16 +181,17 @@ function TimedPromise(fn, {timeout = 150
   return new Promise((resolve, reject) => {
     // Reject only if |throws| is given.  Otherwise it is assumed that
     // the user is OK with the promise timing out.
     let bail = () => {
       if (throws !== null) {
         let err = new throws();
         reject(err);
       } else {
+        log.warn(`TimedPromise timed out after ${timeout} ms`, stack());
         resolve();
       }
     };
 
     timer.initWithCallback({notify: bail}, timeout, TYPE_ONE_SHOT);
 
     try {
       fn(resolve, reject);
@@ -250,17 +252,17 @@ function Sleep(timeout) {
  *     and the window message manager when closing a chrome window.
  *
  * @return {Promise}
  *     A promise that resolves when the message manager has been destroyed.
  */
 function MessageManagerDestroyedPromise(messageManager) {
   return new Promise(resolve => {
     function observe(subject, topic) {
-      logger.debug(`Received observer notification ${topic}`);
+      log.debug(`Received observer notification ${topic}`);
 
       if (subject == messageManager) {
         Services.obs.removeObserver(this, "message-manager-disconnect");
         resolve();
       }
     }
 
     Services.obs.addObserver(observe, "message-manager-disconnect");