An error in SessionStore.#initSession drops saved tab groups
Categories
(Firefox :: Session Restore, defect)
Tracking
()
People
(Reporter: mhynson, Assigned: mhynson)
Details
Within the inner try block of SessionStore.#initSession, this.#savedGroups = state?.savedGroups ?? [] is the last statement (searchfox).
The catch simply logs that "The session file is invalid". If anything earlier in the block throws, #savedGroups stays [], and the next session write saves an empty saved-groups list to disk.
One likely culprit that can throw is #prepDataForDeferredRestore, which converts open tab groups into saved groups for a deferred session (searchfox):
let groupStateToSave = window.groups.find(
groupState => groupState.id == window.tabs[tIndex].groupId
);
let groupToSave = groupsToSave.get(groupStateToSave.id);
If a tab's groupId has no matching entry in window.groups, or the window has no groups key, this throws a TypeError.
| Assignee | ||
Updated•22 days ago
|
| Assignee | ||
Updated•22 days ago
|
| Assignee | ||
Updated•22 days ago
|
Comment 1•21 days ago
|
||
I reproduced this on a clean tree, and the mechanism is exactly as you describe. A deferred session whose tab refers to a group the window does not define ends with:
TypeError: can't access property "id", groupStateToSave is undefined at groupsToSave.get(groupStateToSave.id) in #prepDataForDeferredRestore, and after startup SessionStore.savedGroups is [].
This is the same failure as bug 2087599 (D338378). I updated its test to use your trigger - a tab with an unresolvable groupId - alongside a second one (a window with no _closedTabs). Both are red on a clean tree and green with the patch.
To be explicit about what that patch does and does not do: it keeps state.savedGroups in the catch, so the data survives whatever threw. It does not stop the throw, so the deferred restore is still left half-converted. The guard on groupStateToSave is the other half and is yours to decide. If you would rather track this in one place, I can fold 2087599 into this bug.
| Assignee | ||
Updated•21 days ago
|
| Assignee | ||
Comment 2•20 days ago
|
||
It sounds like you've got a good start to a solution on bug 2087599. Nice work! I pulled down your changes and can confirm that savedGroups does survive trying to restore from an error in the session restore file when there are missing groups. Thank you for adding that trigger in the test. I'll close this bug out as a duplicate of 2087599.
Description
•