Race condition when opening a new window in New Identity
I think that we have a race condition during the new identity.
It's especially visible when loggers try to do something, but we don't have a window yet:
[Exception... "Component returned failure code: 0x80040111 (NS_ERROR_NOT_AVAILABLE) [nsIDocShell.domWindow]" nsresult: "0x80040111 (NS_ERROR_NOT_AVAILABLE)" location: "JS frame :: resource://devtools/server/actors/targets/window-global.js :: get window :: line 422" data: no] window-global.js:422:5
get window resource://devtools/server/actors/targets/window-global.js:422
get global resource://devtools/server/actors/webconsole.js:247
I've got it also when the
TorProtolService tried to log some errors because I had killed
tor to do some tests (so, the result was that the original issues were even more difficult to debug, because I had these errors, instead).
At a certain point I've seen it also with our connection pill and
browser.js in the stack trace, but I don't remember all the details.
I think that at the moment things usually work as expected, except when we have some logs (usually in error states?).
So, I propose
promiseing the new window, and
awaiting for it, either before or after closing the old windows.
I suppose it should not make a big difference, and in any case relying on some race condition to make sure new identity works doesn't seem a good idea.
In this way I could not get any more of these errors.