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
_getWindowForBrowserConsole resource://devtools/server/actors/webconsole.js:269
get global resource://devtools/server/actors/webconsole.js:247
makeDebuggeeValue resource://devtools/server/actors/webconsole.js:470
arguments resource://devtools/server/actors/webconsole.js:2058
map self-hosted:180
prepareConsoleMessageForRemote resource://devtools/server/actors/webconsole.js:2057
onConsoleAPICall resource://devtools/server/actors/webconsole.js:1793
onConsoleAPICall self-hosted:1115
onConsoleAPILogEvent resource://devtools/server/actors/webconsole/listeners/console-api.js:115
onConsoleAPILogEvent self-hosted:1115
CS_recordEvent resource://gre/modules/ConsoleAPIStorage.jsm:174
Redux 3
React 13
dispatchInteractiveEvent self-hosted:1162
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 promise
ing the new window, and await
ing 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.