Bug 1749519 - [devtools] Prevent exception when reloading a page while having devtools opened. r=nchevobbe

Unfortunately, I haven't find any useful attribute on JSWindowActorChild/WindowGlobalChild/BrowsingContext
to detect that things are destroyed, or to be destroyed and avoid calling sendAsyncMessage,
or detect in the exception handler that we got destroyed.

So I'm falling back to ignore the exception based on its message...

Differential Revision: https://phabricator.services.mozilla.com/D135608
This commit is contained in:
Alexandre Poirot 2022-01-11 16:16:33 +00:00
Родитель e58b6a54d9
Коммит 83e6733608
1 изменённых файлов: 21 добавлений и 8 удалений

Просмотреть файл

@ -242,14 +242,27 @@ class DevToolsFrameChild extends JSWindowActorChild {
// This will destroy the content process one
this._destroyTargetActor(watcherActorID);
// And this will destroy the parent process one
this.sendAsyncMessage("DevToolsFrameChild:destroy", {
actors: [
{
watcherActorID,
form,
},
],
});
try {
this.sendAsyncMessage("DevToolsFrameChild:destroy", {
actors: [
{
watcherActorID,
form,
},
],
});
} catch (e) {
// Ignore exception when the JSWindowActorChild has already been destroyed.
// We often try to emit this message while the WindowGlobal is in the process of being
// destroyed. We eagerly destroy the target actor during reloads,
// just before the WindowGlobal starts destroying, but sendAsyncMessage
// doesn't have time to complete and throws.
if (
!e.message.includes("JSWindowActorChild cannot send at the moment")
) {
throw e;
}
}
});
this._connections.set(watcherActorID, {
connection,