From 5aaa18113b1b823d79c88c971395f901bb1d464b Mon Sep 17 00:00:00 2001 From: Alexandre Poirot Date: Wed, 9 Oct 2019 08:03:45 +0000 Subject: [PATCH] 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 --HG-- extra : moz-landing-system : lando --- devtools/shared/fronts/targets/target-mixin.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/devtools/shared/fronts/targets/target-mixin.js b/devtools/shared/fronts/targets/target-mixin.js index 80eb0e269cfc..a7d6ca8d8f1a 100644 --- a/devtools/shared/fronts/targets/target-mixin.js +++ b/devtools/shared/fronts/targets/target-mixin.js @@ -451,8 +451,12 @@ function TargetMixin(parentClass) { 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();