зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1615418 - Do not throw when calling watch/unwatchFront on destroyed Fronts r=daisuke,ochameau
Depends on D62893 The issue here is that we are trying to destroy the workers-listener after the target was destroyed, and calling unwatchFront on a destroyed Front throws. Most of the fronts monitored in workers-listener are handled by the watchFront API, so properly adding onDestroyed handlers fixes some issues. However the rootFront cannot be handled with a similar pattern at the moment. In general, I think making watchFront/unwatchFront safer to call makes sense, but I could also check if the rootFront is already destroyed in workers-listener's destroy Differential Revision: https://phabricator.services.mozilla.com/D62894 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
06deaf08bc
Коммит
79f1be551e
|
@ -125,6 +125,15 @@ class Front extends Pool {
|
|||
* The function is called with the same argument than onAvailable.
|
||||
*/
|
||||
watchFronts(typeName, onAvailable, onDestroy) {
|
||||
if (!this.actorID) {
|
||||
// The front was already destroyed, bail out.
|
||||
console.error(
|
||||
`Tried to call watchFronts for the '${typeName}' type on an ` +
|
||||
`already destroyed front '${this.typeName}'.`
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
if (onAvailable) {
|
||||
// First fire the callback on already instantiated fronts
|
||||
for (const front of this.poolChildren()) {
|
||||
|
@ -147,6 +156,15 @@ class Front extends Pool {
|
|||
* See `watchFronts()` for documentation of the arguments.
|
||||
*/
|
||||
unwatchFronts(typeName, onAvailable, onDestroy) {
|
||||
if (!this.actorID) {
|
||||
// The front was already destroyed, bail out.
|
||||
console.error(
|
||||
`Tried to call unwatchFronts for the '${typeName}' type on an ` +
|
||||
`already destroyed front '${this.typeName}'.`
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
if (onAvailable) {
|
||||
this._frontCreationListeners.off(typeName, onAvailable);
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче