Session and session backups corrupted
I had a crash on firefox, I easily fix lost sessions, when I got updates or crash that lose my active session.
When I try to retrieve my sessions by copying recovery.baklz4 or recovery.jsonlz4 both of them does not work. When clicking on restore previous session, firefox rezzes a few seconds, and then the restore session tab stays blank.
I tried: https://www.jeffersonscher.com/ffu/scrounger.html but the website does not succesfully recovers my firefox session and the tab just crashes, I did manage to convert it to a JSON file.
I did some work on the JSON file myself, through regex and jq tool. I extracted the urls from it. I scrapped my json to make it lighter (I think the problem is from the size of my session), I scrapped the "image", "scp", json objects, trimming the size of the file, it's size was divided by almost 20.
Is there a way to recreate a sane jsonzl4 file? I have the data.
What seems weird is that backups from a few weeks is only around 20MB and by adding a few tabs, it went from 20MB to 80-90MB it's freaking huge.
Is there a way to fix this? recreate a json file and then encrypt it to jsonzl4? What can I scrape safely from my session?
I have been trying to fix this for hours, please help!
Izabrano rješenje
I successfully retrieved my session,
cleaning up the file as I did the first time was enough. My mistake was to name it as sessionstore.json and not as sessionstore.js.
so the problem seemed to be the size of the file. I trimmed my json of "img" "scp" "cookies" "structuredCloneState" and "structuredCloneVersion" what I thought was taking most characters in my file.
For people who runs through the same problem: I used jscher website to create an uncompressed json file (https://www.jeffersonscher.com/ffu/scrounger.html)
To delete sections of my json I installed a tool called JQ, there is an executable available for windows to use as a command line.
this tool can make your files as readable json files, here's the command I used:
jq-win64.exe "del(..|.img?)" "sessionstore(previous_jsonzl4).json" > sessionstore-cleaningup.json (this is a command to run for each json object you want to delete, here it is the "img" object) if you want a compact json (no indentations nor spaces) just add the option "-c":
jq-win64.exe -c "del(..|.img?)" "sessionstore(previous_jsonzl4).json" > sessionstore-cleaningup.json
at last just execute one last time to create a compressed (without spacing) clean file:
jq-win64.exe -c "del(..|.img?)" "sessionstore-cleanedup.json" > sessionstore.js
clean your firefox profile of old session files(make backups). and place your sessionstore.js in your profile, start firefox again, hope it works for you!
Thanks again for the time you took to help me solve my problem Jefferson.
(ps: If jefferson urls scrapping doesn't work for you. You can easily do it through bash: grep -oP '"url":"\K[^"]+' $(ls -t sessionstore.json | sed q) >> urls.txt)
Pročitajte ovaj odgovor sa objašnjenjem 👍 0All Replies (5)
Hi Itsuki, sorry to hear about this problem.
I tried: https://www.jeffersonscher.com/ffu/scrounger.html but the website does not succesfully recovers my firefox session and the tab just crashes, I did manage to convert it to a JSON file.
On the Scrounger, did you try the "fallback" button (see attached screenshot)? It pays less attention to the details of the file structure and just pulls as many URLs as it can.
The session history file includes additional "state" information that helps Firefox restore your tab more fully, such as form field content and session cookies. That is one reason the file can be much larger than expected. But if you don't have a script or other tools to read the JSON structure, it's quite difficult to remove just that stuff and find what you really want.
I did some work on the JSON file myself, through regex and jq tool. I extracted the urls from it. I scrapped my json to make it lighter (I think the problem is from the size of my session), I scrapped the "image", "scp", json objects, trimming the size of the file, it's size was divided by almost 20. Is there a way to recreate a sane jsonzl4 file? I have the data. What seems weird is that backups from a few weeks is only around 20MB and by adding a few tabs, it went from 20MB to 80-90MB it's freaking huge. Is there a way to fix this? recreate a json file and then encrypt it to jsonzl4? What can I scrape safely from my session?
If the JSON file is valid, you may not need to compress it. You can try this:
(1) From inside Firefox, open your current Firefox settings (AKA Firefox profile) folder using either
- "3-bar" menu button > "?" Help > Troubleshooting Information
- (menu bar) Help > Troubleshooting Information
- type or paste about:support in the address bar and press Enter
In the first table on the page, click the "Open Folder" button. This should launch a File Explorer window listing the various files and folders in your profile. (You must be very familiar with all this by now...)
(2) Leaving that window open, switch back to Firefox and Exit, either:
- "3-bar" menu button > "power" button Exit
- (menu bar) File > Exit
Pause while Firefox finishes its cleanup -- a file named sessionstore.jsonlz4 should appear in the folder. (If it never appears, don't be alarmed, but skip Step 3.)
(3) Once Firefox has stopped updating things, while viewing the main level of the profile folder, right-click > Rename sessionstore.jsonlz4 to sessionstoreOLD.jsonlz4
If you see an older sessionstore.js or sessionstore.bak file, move it somewhere else or delete it.
(4) Copy in the other file you want to restore, and rename it with the name appropriate for its format:
- Compressed file such as previous.jsonlz4 => sessionstore.jsonlz4
- Uncompressed file such as previous.js => sessionstore.js
(5) Right-click the sessionstore-backups folder and rename it to sessionstore-backupsOLD to prevent Firefox from using another file in there at startup
(6) Start Firefox and it should read the swapped in sessionstore file and restore whatever was in the substitute file; if you do not have Firefox set to restore your previous windows and tabs automatically, use History > Restore Previous Session
Any luck?
Hello Jscher
On the Scrounger, did you try the "fallback" button (see attached screenshot)? It pays less attention to the details of the file structure and just pulls as many URLs as it can.
I cannot press any button, when I load the file, the website just freeze, and it present to me a page telling me the tab just crashed. (nevermind, just succeeded not working with recovery.jsonzl4 nor recovery.bak, but magically works with previous.jsonlz4 (just a few Ko lighter))
The session history file includes additional "state" information that helps Firefox restore your tab more fully, such as form field content and session cookies. That is one reason the file can be much larger than expected. But if you don't have a script or other tools to read the JSON structure, it's quite difficult to remove just that stuff and find what you really want.
I do have a tool to manipulate json files, this is how I deleted, "img" objects from my json to lighten it. At the end, the only thing I do really want is just the websites showing up at the right place on the right window. Cookies and other extras is not important for my case.
If the JSON file is valid, you may not need to compress it. You can try this: ... If you see an older sessionstore.js or sessionstore.bak file, move it somewhere else or delete it. (4) Copy in the other file you want to restore, and rename it with the name appropriate for its format:Any luck?
- Compressed file such as previous.jsonlz4 => sessionstore.jsonlz4
- Uncompressed file such as previous.js => sessionstore.js
I assume you meant "sessionstore.json" not ".js"
I did everything you said multiple times with all the files at my disposition, except those from a few weeks that do work.
Still does not work I think firefox, does not succesfully read the file. I'm trying to investigate things further, but I'm going blindly, and trying almost random stuff at this point.
My next step is to compare my json files against those from a few weeks, I fear that they would be too different (200 MB diff after decompression from lz4 to json). but I can maybe learn something from it.
If you have any ideas, throw them in! Thanks for the help so far.
Ps: "It is the second time I get this problem, first time I just discarded my corrupted session. I do want to understand where it comes from. First time, it occured after last firefox update."
I compared the files. I have the feeling, that the problem may come from remaining urls in my file "about:sessionrestore", I am asking my self if there is not some kind of nested duplicates because of it, or some infinite loop/ recursion because of it.
Valid file has 5 nested json objects or array max,
invalid file has maybe 15-20 or more nested json arrays.
Izmjenjeno
By now, I think you know more about these files than I do.
Two thoughts:
(1) One of the last names Firefox looks for is sessionstore.js -- that is the legacy file name used before Firefox 33 when lz4 compression began. Firefox never looks for sessionstore.json.
(2) Firefox's Browser Console does not have the same tab crash problems as the web app version, but while I have a decompression script for the Browser Console (Browser Console Snippet to decompress mozlz4 and jsonlz4 files), I don't have the entire Scrounger rewritten to run in the console. I should do that at some point...
Odabrano rješenje
I successfully retrieved my session,
cleaning up the file as I did the first time was enough. My mistake was to name it as sessionstore.json and not as sessionstore.js.
so the problem seemed to be the size of the file. I trimmed my json of "img" "scp" "cookies" "structuredCloneState" and "structuredCloneVersion" what I thought was taking most characters in my file.
For people who runs through the same problem: I used jscher website to create an uncompressed json file (https://www.jeffersonscher.com/ffu/scrounger.html)
To delete sections of my json I installed a tool called JQ, there is an executable available for windows to use as a command line.
this tool can make your files as readable json files, here's the command I used:
jq-win64.exe "del(..|.img?)" "sessionstore(previous_jsonzl4).json" > sessionstore-cleaningup.json (this is a command to run for each json object you want to delete, here it is the "img" object) if you want a compact json (no indentations nor spaces) just add the option "-c":
jq-win64.exe -c "del(..|.img?)" "sessionstore(previous_jsonzl4).json" > sessionstore-cleaningup.json
at last just execute one last time to create a compressed (without spacing) clean file:
jq-win64.exe -c "del(..|.img?)" "sessionstore-cleanedup.json" > sessionstore.js
clean your firefox profile of old session files(make backups). and place your sessionstore.js in your profile, start firefox again, hope it works for you!
Thanks again for the time you took to help me solve my problem Jefferson.
(ps: If jefferson urls scrapping doesn't work for you. You can easily do it through bash: grep -oP '"url":"\K[^"]+' $(ls -t sessionstore.json | sed q) >> urls.txt)
Izmjenjeno