Bug 1565263 - Make TargetMixin.destroy more synchronous. r=jdescottes
authorAlexandre Poirot <poirot.alex@gmail.com>
Wed, 09 Oct 2019 08:03:45 +0000
changeset 496928 b5e0f6f76dd6b71e168419949b3e567e33507788
parent 496927 263886b0a46b9c355307989d69c6e7476a4ede9b
child 496929 96917f5eb072c52c4a9d005d40123d8af1b1354f
push id36671
push usershindli@mozilla.com
push dateWed, 09 Oct 2019 16:04:03 +0000
treeherdermozilla-central@0efb4f268d16 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjdescottes
bugs1565263
milestone71.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 1565263 - Make TargetMixin.destroy more synchronous. r=jdescottes Protocol.js's Front and Pool's destroy are not expected to be async. But TargetMixin.destroy is. It makes DebuggerClient.close do not wait for all Target fronts destroys correctly. The client close method calls the cleanup method of all the pools. Top level fronts are pools. Target fronts are still self managed and so are pools. And so, when we close the toolbox, the target destroy is still pending after toolbox.destroy is resolved. Differential Revision: https://phabricator.services.mozilla.com/D46221
devtools/shared/fronts/targets/target-mixin.js
--- a/devtools/shared/fronts/targets/target-mixin.js
+++ b/devtools/shared/fronts/targets/target-mixin.js
@@ -446,18 +446,22 @@ function TargetMixin(parentClass) {
         return this._destroyer;
       }
 
       this._destroyer = (async () => {
         // Before taking any action, notify listeners that destruction is imminent.
         this.emit("close");
 
         for (let [, front] of this.fronts) {
-          front = await front;
-          await front.destroy();
+          // If a Front with an async initialize method is still being instantiated,
+          // we should wait for completion before trying to destroy it.
+          if (front instanceof Promise) {
+            front = await front;
+          }
+          front.destroy();
         }
 
         this._teardownRemoteListeners();
 
         this.threadFront = null;
 
         if (this.shouldCloseClient) {
           try {