Fight for the Internet 1!

Wednesday, May 29, 2013

Firefox sessionstore.js recovery

So randomly today Firefox corrupted itself while I was using Google Drive. It stopped allowing me to edit the document, then refused to reload the page, or any other Google Drive document. Then when I closed and reopened the browser, all my 100+ tabs in various tab groups were gone, including my pinned tabs. I suspect it was because I had two Firefox windows open at the same time that might have caused the problem, but I'm honestly not sure.

Here is the simple way I managed to restore the tab data.

For those who don't know, the sessionstore.js is where Firefox keeps your tab data. Checking my Firefox profile's directory (which was ~/.firefox/MyBrowser/), luckily my sessionstore.js and sessionstore.bak file were both large and full of the tab data. You should find those two files and make a backup of them immediately.

The sessionstore.js is in fact one big JSON file.

On Ubuntu, I installed the package "yajl-tools" which stands for "Yet Another JSON Library". I did this to give me the JSON commands: json_verify and json_reformat.

My first thought was the sessionstore.js was somehow corrupt, but json_verify did not agree with me. Sending my sessionstore.js to json_reformat


I ran this command from command line to check if my file was okay:
cat sessionstore.bak| json_verify
If you get a message saying okay, then proceed to the next step. This command reformats the
cat sessionstore.bak | json_reformat >sessionstore.js
Next open the  sessionstore.js. I found that all the tabs were not being restore because they had been moved to the '_closedWindows' section.

View of my sessionstore.js from the top:
 {
    "windows": [
        {
            "tabs": [
                {
                    "entries": [
                        {
            ..........

This section had no real tabs. I could tell this should have been filled with data but was empty. Lower down in the file was the "_closedWindows":, which is where all my tabs had gone.

  "_closedWindows": [                                                                                                                 
        {
            "tabs": [
                {
                    "entries": [
                        {
                            "url": "https://mail.google.com/mail/u/0/?ui=2&shva=1#inbox?compose=new",
                            "title": "Inbox (7) - bob@gmail.com - Gmail",
                            "subframe": true,
                            "ID": ....,
                            "docshellID": ....,
                            "docIdentifier": ...
                        },
                        {
                            "url": "https://mail.google.com/mail/u/0/?ui=2&shva=1#inbox?compose=new",
                            "title": "Inbox (7) - bob@gmail.com - Gmail",
                 ..............

So I opened the file in sessionstore.js, copied the the 'tabs' section(including the header) under '_closedWindows' to 'windows' where it should have been, deleted the original and everything is running smoothly again.

Final form of my of my sessionstore.js from the top:
 {
    "windows": [
        {  
            "tabs": [
                {
                    "entries": [
                        {
                            "url": "https://mail.google.com/mail/u/0/?ui=2&shva=1#inbox?compose=new",
                            "title": "Inbox (7) - bob@gmail.com - Gmail",
                            "subframe": true,
                            "ID": ....,
                            "docshellID": ....,
                            "docIdentifier": ...
                        },
                        {
                            "url": "https://mail.google.com/mail/u/0/?ui=2&shva=1#inbox?compose=new",
                            "title": "Inbox (7) - bob@gmail.com - Gmail",
                 ..............
 Hope that helps. Source taken from here: http://dag.wieers.com/blog/what-if-firefox-loses-your-tabs


No comments:

Post a Comment