Bug: TabStateFlusherInternal.flush throws intermittently
Status: RESOLVED
Priority: --
Resolution: WORKSFORME
Created: 2021-11-15 10:38:30+00:00
Resolved: 2024-05-16 12:22:39+00:00

There is a series of intermittents that carry a similar sequence of events:

```
[task 2021-11-10T11:51:23.357Z] 11:51:23     INFO - PID 8821 | [Parent 8821, IPC I/O Parent] WARNING: Failed to launch tab subprocess: file /builds/worker/checkouts/gecko/ipc/glue/GeckoChildProcessHost.cpp:750
[task 2021-11-10T11:51:23.364Z] 11:51:23     INFO - PID 8821 | JavaScript error: chrome://browser/content/tabbrowser.js, line 1909: NS_ERROR_ILLEGAL_VALUE: Component returned failure code: 0x80070057 (NS_ERROR_ILLEGAL_VALUE) [nsIWebProgress.removeProgressListener]
[task 2021-11-10T11:51:23.367Z] 11:51:23     INFO - PID 8821 | JavaScript error: chrome://browser/content/tabbrowser.js, line 1909: NS_ERROR_ILLEGAL_VALUE: Component returned failure code: 0x80070057 (NS_ERROR_ILLEGAL_VALUE) [nsIWebProgress.removeProgressListener]
[task 2021-11-10T11:51:23.594Z] 11:51:23     INFO - PID 8821 | 1636545083586	Marionette	ERROR	TypeError: can't access property "addMessageListener", this.mm is null(chrome://remote/content/marionette/dom.js:50:5) JS Stack trace: WebElementEventTarget@dom.js:50:5
[task 2021-11-10T11:51:23.594Z] 11:51:23     INFO - PID 8821 | switchToTab@browser.js:398:26
[task 2021-11-10T11:51:23.596Z] 11:51:23     INFO - PID 8821 | GeckoDriver.prototype.setWindowHandle@driver.js:1232:35
[task 2021-11-10T11:51:23.596Z] 11:51:23     INFO - PID 8821 | GeckoDriver.prototype.switchToWindow@driver.js:1172:18
[task 2021-11-10T11:51:23.596Z] 11:51:23     INFO - PID 8821 | despatch@server.js:306:40
[task 2021-11-10T11:51:23.596Z] 11:51:23     INFO - PID 8821 | execute@server.js:279:16
[task 2021-11-10T11:51:23.596Z] 11:51:23     INFO - PID 8821 | onPacket/<@server.js:252:20
[task 2021-11-10T11:51:23.596Z] 11:51:23     INFO - PID 8821 | onPacket@server.js:253:9
[task 2021-11-10T11:51:23.596Z] 11:51:23     INFO - PID 8821 | _onJSONObjectReady/<@transport.js:500:20
[task 2021-11-10T11:51:23.596Z] 11:51:23     INFO - NoSuchWindowException on command, setting status to CRASH
[task 2021-11-10T11:51:23.597Z] 11:51:23     INFO - TEST-UNEXPECTED-CRASH | /service-workers/service-worker/state.https.html | expected OK
[task 2021-11-10T11:51:23.598Z] 11:51:23     INFO - TEST-INFO took 617ms
[task 2021-11-10T11:51:23.604Z] 11:51:23     INFO - PID 8821 | 1636545083604	Marionette	INFO	Stopped listening on port 47567
[task 2021-11-10T11:51:23.784Z] 11:51:23     INFO - PID 8821 | WARNING: A blocker encountered an error while we were waiting.
[task 2021-11-10T11:51:23.787Z] 11:51:23     INFO - PID 8821 |           Blocker:  SessionStore: flushing all windows
[task 2021-11-10T11:51:23.788Z] 11:51:23     INFO - PID 8821 |           Phase: quit-application-granted
[task 2021-11-10T11:51:23.788Z] 11:51:23     INFO - PID 8821 |           State: {"total":-1,"current":-1}
[task 2021-11-10T11:51:23.788Z] 11:51:23     INFO - PID 8821 | WARNING: TypeError: can't access property "sendAsyncMessage", mm is null
```

The session store related part points to [`flush(browser)`](https://searchfox.org/mozilla-central/rev/0fd5870b0cea42f139b0a605a7fc006128160872/browser/components/sessionstore/TabStateFlusher.jsm#124).

It might well be just a symptom of other things going wrong earlier, but it looks like `flush(browser)` could benefit from some hardening regarding missing properties in any case.