Closed Bug 668359 Opened 13 years ago Closed 3 years ago

Session Restore: sessionstore.js is ignored (corrupted JSON can be fixed manually!)

Categories

(Firefox :: Session Restore, defect)

47 Branch
All
Other
defect
Not set
critical

Tracking

()

RESOLVED WORKSFORME

People

(Reporter: rhialto, Unassigned)

References

(Blocks 1 open bug)

Details

(Keywords: dataloss, steps-wanted)

User Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:5.0) Gecko/20100101 Firefox/5.0
Build ID: 20110615151330

Steps to reproduce:

Ok now this is the second it happens to me.

Both at work (XP) and at home (Win7) Firefox was upgraded to version 5.


Actual results:

Last week at work for no apparent reason I lost all my opened tabs on startup.  I looked for help without much succes.  I read many time to go into option making sure bla bla bla...  but I haven't modified a setting so I knew everything was ok and I checked over to make sure.

Anyway, I endend up opening the sessionstore backup file and done a search for the string "entries" then I was able to copy & paste the url for each tab I recreated.

Today I just got home and same thing happen, I start firefox and no tabs!  I seach on the web if this is happening a lot with firefox 5 and I've read a few thread but again the canned answer to try lokking at this and that.

At one point last week after looking at the sessionstore structure I thought I had the solution but like I wrote I endend up recreating all my tabs.

This time I decided to give a go editing the file and I was successful!  I hope that all those with the same problem will find my potential fix and I hope it will work for them.

FIX:

Use a text editor and open the good sessionstore.bak is you still have it.

If the file begin like this:

{"windows":[],"selectedWindow":0,"_closedWindows":[{"tabs":[{"entries":[{"url":"https://

Only delete:

],"selectedWindow":0,"_closedWindows":[

So you get:

{"windows":[{"tabs":[{"entries":[{"url":"https://

TADA!  All tabs are back!


Now I will let engineers take a look at this.  I don't know why this is happening.  I wonder why is such case, firefox is not smart enough to simply scan the file for all the URLs and restore from that, it would save a lot of trouble for many!
Severity: normal → critical
There are a couple related bugs, but the reason it's happening boils down to this:

When you're quitting Firefox, you have a single window with only blank tabs open. You quit Firefox by closing the last window.

Some solutions until this gets fixed properly:
 * Quit Firefox by quitting (Menu > Exit/Quit)
 * Don't close a window with only blanks tab open
Wow, this bug report is not getting any attention. Firefox 12 here and the problem is still present, even more people complain now... Firefox should do this by himself(the fix)...
Since version 12 Firefox has problems with Flash. When I close youtube tabs most of the time they keep playing in the background, if I close Firefox it stops but this time Firefox only imitated closing and the "Closed Firefox with closed youtube tabs" was still playing the youtube videos in the background so I went in the Task Manager and from the Processes tab saw that firefox.exe wasn't releasing the memory and wasn't planning to close so I closed it the forced way and when I relaunched it all the tabs were lost...
Replacing "sessionstore.js" from the "sessionstore.bak" file didn't work because every time I was launching Firefox the file got replaced with a ~700 Bytes "sessionstore.js" instead of my 4 MB file. Opening "about:sessionrestore" was showing me a blank list. This solution solved my problem, thanks to the reporter!
Happened to me today (Firefox 12 on Win7 x64).
It is strange since basically the same session restored just fine this morning, but this afternoon it just ignored the 680kb sessionstore.js and replaced it with a 7kb one each time I started it.
Deleting ],"selectedWindow":0,"_closedWindows":[ fixed it.
It also opened 2 windows from some days ago, but I guess that's expected, since I deleted the part that told it which windows were actually in use.
I'm the OP and wanted to let you know that since then I installed http://sessionmanager.mozdev.org/ and this never happened again.

I have no idea WHY this is not built-in Firefox.
I can confirm this bug for Firefox 16.0.2 on Mac OS X 10.8.2.

Somehow Firefox replaced my 3.2 MB sessionstore.js file with an empty one. When I replaced it with the sessionstore.bak file, still no session was restored (and the "restore last session" menu was greyed out).

After editing the first line as described above, the "restore last session" menu came back and successfully reopened the tabs.
Still there with FF19 on Linux...  json_verify says sessionstore.js is OK; but with over 2300 URLs, all I get trying to restore history is 1 window and 2 "about:blank" tabs.  No luck restoring yet... Sure could use a clue stick as to what FF doesn't like about an apparently good sessionstore.js...
I can confirm that it happens with FF 19.0.2, too (Windows XP x86).

I just got a blank firefox like opening without any session restore. Just renaming the .bak file lead to the same result.

After doing the fix, I got all my tabs back, in 3 windows.

Thanks a lot!
Confirming, this still happens in Firefox 22. Had trouble with this for a couple of times...
Confirming, this still happens with Firefox 26 (after automatic repositories update in Ubuntu 12.10). The fix works (thanks !).
Confirming, Firefox 26 under Windows Server 2003 x86, Fix worked again.
Confirming Firefox 27.0 under Windows 7 x64, Fix worked for me.
Still here in 28.0 too, many thanks for the workaround rhialto! Fair enough, FF is the only browser that can handle hundreds of tabs mostly without crashing.
So, firefox just updated and since then nothing but crashes...and now I cant reopen my tabs. When I tried to open the backup file (I have more of them, this happend before) which was ca. 40 mb, I got a blank document of 800 pages. I tried to open it in word, wordpad, editor....all of them seem to be empty. How the hell is that possible? And how do I fix it?
bug is still there in firefox 31.6.0
Still running 31.6.0?  37 is current!

I thought with session backup improvements in 33 (http://www.ghacks.net/2014/06/27/mozilla-launches-improved-session-restore-firefox-33/) all this was fixed?

Anyweay, like I said 3 years ago (see Comment 4) since I installed the session manager I never lost a session again on any computer.

But I guess it's ok to still report the problem for people running plain Firefox though...  maybe one day Firefox will ship with session manager built-in.
31.6.0 is still latest firefox ESR, which is what we're using (running latest current-of-the-day is not an option here, nor are random addons so easy to deploy).

Anyway just noting that bug is still present in 31.6.0 (and workaround by manually editing sessionstore.js from original bug report still helps). 

It this particular case, it seems that external program (urlview(1)) called firefox to open a new window with URL, and firefox crashed halfway through. On restart, sessionstore.js was silently nuked. Copying sessionstore.bak over sessionstore.js and starting FF didn't help (FF again silently trucated sessionstore.js). But editing it and then copying saved the day (as indicated in original bug report).

It would be great if FF33 fixed that issue (do you know that or just guess?), as that would mean that next ESR FF (38.0) would have fix implemented.
Using FF 38.0 for ubuntu and the bug is still available. I fixed the file manually as described (with slight changes but similar) and all TABs are back.

Thank you for the FIX as manual workaround!

@Developers: Why is this still not fixed within FF?!?
The bug is still present in Firefox 40.0.3.

I was able to fix it using the steps Rhialto posted 4 years ago. 

Please fix this.
This behaviour and bad surprise happened with 41.0.2.

Both previous and recovery.js contained the opened tabs, and no « ],"selectedWindow":0,"_closedWindows":[ » before the end of the file at 24K characters or something (1)
json_verify stated both files where fine.
After copying any in the profile's root folder (after closing Firefox), they were ignored: previous tabs were displayed for a very brief moment... then reverted to the last two opened tabs.
Frustration here.
What worked:
- close Firefox
- restore previous.js
- start Firefox in safe mode: sessionstore.js was used and all tabs restored!
- restart with add-ons enabled: all tabs show up.

Scratching my head --on top of a bookmarks sync hell that eats time like a $200 old car each time you need it to run.
Edit: old previous.js and new recovery.js (that I also backed up after recovering session worked) diff by a few bytes. I dunno how to diff them properly since they're on a single line of 24K characters. Suggestion on this are welcome!
Things getting better in this location.
Sessions were ~never restored (but a couple of tabs) with Firefox 41.
Have not seen this issue with Firefox 42 on the same three profiles with similary looking sessions.
It's back! I didn't have this issue for a very long time, but after updating to Firefox 47.0 it just happened again. I had to delete ],"selectedWindow":0,"_closedWindows":[ and got my tabs back!
Status: UNCONFIRMED → NEW
Ever confirmed: true
Version: 5 Branch → 47 Branch
See Also: → 1028717, 1015753
Summary: sessionstore.js is ignored (FIX inside!) → Session Restore: sessionstore.js is ignored (corrupted JSON can be fixed manually!)
This just happened to me in Firefox 49, in my case because Amazon had spawned a second window and I had accidentally closed my main window with all my tabs before closing the extra Amazon window.

The workaround in the first comment of this thread (making a copy of previous.js and deleting the part with `_closedWindows`, so that what was in there is now in `windows`, saved the day for me.

Naively, it seems an easy fix to me to just make it so that you cannot just restore (Shift+Ctrl+T) the *last* window from the last session, but *all* windows from the previous session (e.g. pressing Shift+Ctrl+T again would bring back the second last closed window). What do you think?

Hey rhialto,
Can you still reproduce this issue or should we close it?

Flags: needinfo?(rhialto)

Didn't happen for a very, very long time.

wow 10 yeas ago Firefox 5! hehe I'm good now. Seems I can't close it myself so yes you can close it.

Flags: needinfo?(rhialto)

Marking this as Resolved > Worksforme based on the last comments.

Status: NEW → RESOLVED
Closed: 3 years ago
Resolution: --- → WORKSFORME
You need to log in before you can comment on or make changes to this bug.