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
This commit is contained in:
Alexandre Poirot 2019-10-09 08:03:45 +00:00
parent 52a0e9273a
commit 5aaa18113b

View File

@ -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();