Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Temporary containers not removed with new sync feature #371

Open
neekt opened this issue Feb 21, 2020 · 67 comments · Fixed by mozilla/multi-account-containers#2231
Open

Comments

@neekt
Copy link

neekt commented Feb 21, 2020

  • Temporary Containers Version: 1.7
  • Firefox Version: 73.0

I've just noticed that with Firefox's new Multi-Account Containers sync feature, temporary containers are being synced across browsers on different machines, and then not removed, even when all instances of the container (e.g., tmp4) are closed in both browsers. Completely closing both browsers and then re-opening doesn't get rid of them either. They can be manually removed, if you manually remove them from both browsers and then sync Firefox, but in my case I have found dozens of temporary containers are being synced and kept, so this is not practical.

I assume it's possible to deactivate the container syncing feature (it asks whether to activate it upon update to the new Multi-Account Containers version), but I actually find it quite useful. So if there is some way to prevent temporary containers from being synced (ideally), or (less ideally) to allow them to still be automatically removed even after they've synced, that would be great.

This is using Automatic Mode, deleting no longer needed temporary containers after the last tab in it closes, and reusing available numbers in settings. Everything else is set to default.

@stoically
Copy link
Owner

stoically commented Feb 21, 2020

That's unfortunate. I've mentioned this during review of the sync feature, and it was said that it should work. I'll look into it at some point, but it might be worth filing this in the MAC issues as well, since in theory the containers should get deleted eventually.

@CartCaved
Copy link

Maybe it's because @neekt is reusing available numbers, and the dedupe gets screwed up, as per your exchange here mozilla/multi-account-containers#1611 (comment) and the list of deleted containers gets confused?

@ChrisWiegman
Copy link

I'm hitting this myself but turning off sync hasn't helped. I have 1,000s of containers and manually deleting (which is not fun) only works for a minute or two until they all come back.

@stoically
Copy link
Owner

If turning off sync in MAC lets the container reappear, then that's definitely a MAC bug that you might want to report there.

Did you have "Reuse available numbers" active in TC while MACs sync was active?

@okradonkey
Copy link

okradonkey commented Mar 6, 2020

Just a heads-up; I have the same issue of TCs not getting deleted, but I'm not using the MAC extension at all - I'm using Containerise - so the issue might not be in MAC itself, but rather elsewhere in Firefox or the Sync system. I only use one computer but I do have Sync enabled. TC is set to keep counting.

Edit - Sorry, false alarm. I did have about 20 TCs lingering in my list (which is why I was here to begin with) but they may have been leftover from when I was trying out the updated MAC. I had MAC with its sync enabled for a few days before deciding to disable it and continue with Containerise.

Now (without MAC), after deleting the leftover TCs and trying to reproduce the issue, I've found that everything is working perfectly; newly abandoned TCs are deleted immediately and don't reappear. Thanks for your help.

@stoically
Copy link
Owner

stoically commented Mar 6, 2020

@okradonkey TCs not getting deleted at all without MAC is a different issue (since the container sync is part of MAC), and definitely shouldn't happen. Would you mind:

  • Setting the removal delay to instant (Preferences > "Delete no longer needed Temporary Containers" > "After the last tab closes")
  • Preparing an debug log
  • Opening and closing an TC
  • Posting the debug log as new issue?

@dveditz
Copy link

dveditz commented Mar 26, 2020

@sh4r1k7
Copy link

sh4r1k7 commented Apr 18, 2020

Can anyone suggest a way to delete all the containers? I have over a thousand, it's inhumane to delete them by hand. I turned off sync but they're still there slowing everything down.

@stoically
Copy link
Owner

stoically commented Apr 18, 2020

@3dc1d3

You could remove all containers that aren't currently active temporary containers, though that will remove all your permanent containers that you might want to keep.

To remove all containers except currently active temporary containers:

  • Backup your profile(s)
  • Navigate to about:debugging#/runtime/this-firefox
  • Click "Inspect" right to Temporary Containers
  • Click "Console"
  • Insert into the console
    Edit: Might want to use Temporary containers not removed with new sync feature #371 (comment) instead
  • If you're getting a "Scam warning", type "allow pasting" into the console, remove it again, and then insert code from last step again
  • Press Enter and wait for the console to print done

@stoically
Copy link
Owner

Related issue over at MAC: mozilla/multi-account-containers#1675

@Vinnl
Copy link

Vinnl commented Apr 22, 2020

Thanks @stoically. Unfortunately I just used that to remove more containers than I wanted due to an unfortunate press of the Enter key, but for those who want to avoid that, this snippet should only remove containers starting with tmp:

const containers = await browser.contextualIdentities.query({});
await Promise.all(containers.map(container => {
  if (tmp.container.isTemporary(container.cookieStoreId)) return;

  const prefix = 'tmp';
  if (container.name.substring(0, prefix.length) !== prefix) {
    return;
  }

  // could add exceptions here for other permanent containers,
  // e.g. by looking into the containers.json, like so:
  // if (container.cookieStoreId === "firefox-container-123") return;

  return browser.contextualIdentities.remove(container.cookieStoreId);
}));
console.log("done");

(People using a different prefix can replace tmp in const prefix = 'tmp'; with their prefix.)

@sh4r1k7
Copy link

sh4r1k7 commented Apr 22, 2020

thanks @stoically and @Vinnl - finally got around to it. 👍

@serhumanos
Copy link

hi, i try the @Vinnl code, it removes all tmp# containers.. but after a minute, all of them reappear.
i disabled firefox sync for addons, and MAC sync too, and tmp# (and other containers not "tmp#" but deleted on the past, are keep reappearing)
my firefox is too slow, is there any other alternative?

@crssi
Copy link

crssi commented May 6, 2020

Would you care to uninstall MAC and try again?

@serhumanos
Copy link

Would you care to uninstall MAC and try again?

i broke my firefox profile doing the last operation.
i load an old backup of my profile, then deactivate sync for my firefox account (for now i prefered to leave manual) and the problem is not present now (i know this is not a solution)
i had to block the access to profile/wave/logs, because the directory continous creating a lot of log files that collapse my disk space.

i am wating for a real solution for this, if you want i can try do something else (after re-backup my profile again xD)

thanks!

@abulgatz
Copy link

abulgatz commented Aug 6, 2020

Anyone have any luck with any workarounds?

@krishnanunnir
Copy link

I am also facing this issue, what is worse is due to some bug, 100 temporary containers were created and they are not getting deleted.

@svendsvin
Copy link

Same here. Script does not work. The massive amount of tmp containers really slows down FF.

@krishnanunnir
Copy link

@svendsvin You can delete the containers in a much easier way by going to Container Settings in Preferences.

@avian2
Copy link

avian2 commented Aug 13, 2020

To spare anyone else the time it took me to find the menu @krishnanunnir is talking about. It's not in the add-on preferences. It's in the main Firefox preferences, under the "General" tab.

image

@kaushikgopal
Copy link

kaushikgopal commented Aug 14, 2020 via email

@rob-miller
Copy link

"about:preferences#containers" is really helpful, would still be very useful to have a button in the Temporary Containers controls somewhere to 'delete all temporary containers now'. If there's a disagreement with MAC sync at some point it seems like I could just shutdown browsers and clear them individually using this button.

@darthvader666uk
Copy link

actually the quickest way is to just type "about:preferences#containers" in the url bar. I have it bookmarked just for this purpose :)

thank you!

@IssueHuntBot
Copy link

@stoically has cancelled funding for this issue.(Cancelled amount: $50.00) See it on IssueHunt

@stoically
Copy link
Owner

Opened a PR over in MAC: mozilla/multi-account-containers#2231

@onebod
Copy link

onebod commented Feb 4, 2022

How do I simply delete all these TCs without doing it one-by-one via MAC?

image

@Valentin-N
Copy link

I've used Containers Helper in the past to mass delete containers.

@neekt
Copy link
Author

neekt commented Feb 25, 2022

I've used Containers Helper in the past to mass delete containers.

This extension was helpful for mass deleting all the tmp containers that kept syncing - thanks! - but no containers are syncing at all now that that mess is cleaned up.

Seems the mass of synced containers broke something on the back end.

@avian2
Copy link

avian2 commented Feb 25, 2022

@neekt You probably hit the storage quota on the sync server. See my comment about "HTTP 507 Insufficient Storage" error above.

I've heard that resetting your account password (as in, going through the "forgot password" flow) fixes that because that deletes everything stored server side. I have not tried that myself (yet), so I can't say from first hand if it works or not.

@neekt
Copy link
Author

neekt commented Feb 26, 2022

@avian2 I just reset my account password via forgot password, and containers still aren't syncing at all.

I'm not sure how storage quotas work on the server, but newly added bookmarks and extensions are still syncing.

Sync is enabled in the Firefox Multi-Account Containers extension on both machines I'm testing this on.

@avian2
Copy link

avian2 commented Feb 26, 2022

I'm not sure how storage quotas work on the server, but newly added bookmarks and extensions are still syncing.

That is my experience as well. Only the multi-account containers add-on sync is affected by this problem.

If I leave the sync enabled in Multi-Account containers, every once in a while Firefox will still download something like 8000 tmpxxxx containers from the server (which makes Firefox UI seriously unresponsive). I then have to run @vinni's console script to remove them. The deletion won't sync back to the server, so I tend to just leave sync disabled these days.

You can enter "about:sync-log" in the URL bar and search for "Insufficient Storage" in the files there to see if this is still the same error happening for you after you did the "forgot password" thing. The files are ordered by date, so find one that was created after you reset the password.

@neekt
Copy link
Author

neekt commented Mar 2, 2022

If I leave the sync enabled in Multi-Account containers, every once in a while Firefox will still download something like 8000 tmpxxxx containers from the server

I haven't had this happen simply by leaving it enabled, but I did try to disabling and re-enabling containers in the browser yesterday, after which over one thousand tmp containers were synced to my browser 🙄

I can only conclude that resetting the password doesn't delete container data, despite the warning on accounts.firefox.com about everything being removed from the server when you do this.

@cyrossignol
Copy link

cyrossignol commented Apr 14, 2022

Just ran into this today. @Vinnl's solution in #371 (comment) helped, but my extension's sync was still bricked, and it kept pulling all of the dead tmp containers. I extended the code a bit to clean up the sync storage as well, and I had to run through the steps below for each Firefox profile/computer where I use the extension. Dumping the full process here for my future reference and hope it helps someone.

  1. Open a new tab and go to about:debugging#/runtime/this-firefox
  2. Click the "Inspect" button next to Firefox Multi-Account Containers (not Temporary Containers!)
  3. Click the "Console" tab
  4. Enter the following code and press enter (change the prefix variable if needed):
// Your temporary containers prefix:
// WARNING: this script removes any container with this prefix regardless of the origin!
const prefix = 'tmp';

// First, turn off sync to speed up the following steps. This is the same as the "Enable
// sync" checkbox in the Multi-Account Containers options page.
// IMPORTANT: leave this disabled until you finish fixing all of your Firefox profiles.
await browser.storage.local.set({ syncEnabled: false });

// Delete local containers that start with `prefix`:
const containers = await browser.contextualIdentities.query({});
await Promise.allSettled(containers.map(container => {
  if (container.name.startsWith(prefix)) {
    return browser.contextualIdentities.remove(container.cookieStoreId);
  }
}));

// Delete containers from Multi-Account Containers' sync storage that start with `prefix`:
const data = await browser.storage.sync.get();
const keys = Object.keys(data).filter(k => data[k].name && data[k].name.startsWith(prefix));
await browser.storage.sync.remove(keys);

// If your sync is already broken, you may need to delete the following too. This list
// is one reason why sync breaks. The extension tries to put every deleted container 
// ID here to notify your other profiles, and this can bump the sync storage over the 
// quota limit:
await browser.storage.sync.remove('deletedIdentityList');

After that, I did a manual sync for good measure (about:preferences#sync → Sync Now). Repeat the whole thing for each computer with synced temp containers. Subsequent Firefox instances may put temp containers back into your Firefox account sync storage when they start, but these appear to go away when finishing the steps on that profile. I did have to re-do an earlier profile after finishing another computer. The sync did eventually stabilize, and I can sync persistent containers normally again.

At this point, the container sync is still disabled from the code above. Unfortunately, I don't see a way to make sync reliable without something like @stoically's PR at mozilla/multi-account-containers#2231. In the meantime, it seems as if I can run manual syncs when needed:

  1. Close/delete the temp containers
  2. Enable the Multi-Account Containers' sync option
  3. Force a Firefox account sync
  4. Disable the Multi-Account Containers' sync option again

@vbatts
Copy link

vbatts commented May 1, 2022

crosslinking mozilla/multi-account-containers#2349 because I just opened it, then found this extensive issue already in progress

@FlorianWendelborn
Copy link

The related PR that allows excluding containers from sync via regex was just merged: mozilla/multi-account-containers#2231 (comment)

So, hopefully, the next version of multi-account-containers will work flawlessly ❤️

@derkallevombau
Copy link

derkallevombau commented Jul 29, 2022

Just ran into this today. @Vinnl's solution in #371 (comment) helped, but my extension's sync was still bricked, and it kept pulling all of the dead tmp containers. I extended the code a bit to clean up the sync storage as well, and I had to run through the steps below for each Firefox profile/computer where I use the extension. Dumping the full process here for my future reference and hope it helps someone.

1. Open a new tab and go to `about:debugging#/runtime/this-firefox`

2. Click the "Inspect" button next to **Firefox Multi-Account Containers** (not Temporary Containers!)

3. Click the "Console" tab

4. Enter the following code and press enter (change the `prefix` variable if needed):
// Your temporary containers prefix:
// WARNING: this script removes any container with this prefix regardless of the origin!
const prefix = 'tmp';

// First, turn off sync to speed up the following steps. This is the same as the "Enable
// sync" checkbox in the Multi-Account Containers options page.
// IMPORTANT: leave this disabled until you finish fixing all of your Firefox profiles.
await browser.storage.local.set({ syncEnabled: false });

// Delete local containers that start with `prefix`:
const containers = await browser.contextualIdentities.query({});
await Promise.allSettled(containers.map(container => {
  if (container.name.startsWith(prefix)) {
    return browser.contextualIdentities.remove(container.cookieStoreId);
  }
}));

// Delete containers from Multi-Account Containers' sync storage that start with `prefix`:
const data = await browser.storage.sync.get();
const keys = Object.keys(data).filter(k => data[k].name && data[k].name.startsWith(prefix));
await browser.storage.sync.remove(keys);

// If your sync is already broken, you may need to delete the following too. This list
// is one reason why sync breaks. The extension tries to put every deleted container 
// ID here to notify your other profiles, and this can bump the sync storage over the 
// quota limit:
await browser.storage.sync.remove('deletedIdentityList');

After that, I did a manual sync for good measure (about:preferences#sync → Sync Now). Repeat the whole thing for each computer with synced temp containers. Subsequent Firefox instances may put temp containers back into your Firefox account sync storage when they start, but these appear to go away when finishing the steps on that profile. I did have to re-do an earlier profile after finishing another computer. The sync did eventually stabilize, and I can sync persistent containers normally again.

At this point, the container sync is still disabled from the code above. Unfortunately, I don't see a way to make sync reliable without something like @stoically's PR at mozilla/multi-account-containers#2231. In the meantime, it seems as if I can run manual syncs when needed:

1. Close/delete the temp containers

2. Enable the Multi-Account Containers' sync option

3. Force a Firefox account sync

4. Disable the Multi-Account Containers' sync option again

Thank you very much for this.

It didn't work for me because the name property of a temporary container object looked like this: "⌚Temporary Container 119".
So I placed .substr(1) before .startsWith(prefix):

await Promise.allSettled(
	containers.map(
		container =>
		{
			if (container.name.substr(1).startsWith(prefix))
			{
				return browser.contextualIdentities.remove(container.cookieStoreId);
  			}
		}
	)
);

...

const keys = Object.keys(data).filter(k => data[k].name && data[k].name.substr(1).startsWith(prefix));

Then it worked flawlessly.

@smlx
Copy link

smlx commented Nov 1, 2022

If you're using wayland on Linux this script might help to clean up tmp containers. Go to about:preferences#containers, run this command in a terminal, and switch focus back to the browser window in the first three seconds. You might need to adjust the number of tabs.

sleep 3; for i in $(seq 10); do wtype -k tab -k tab -k tab -k tab -k tab -k tab -k space; sleep 0.1; done

Once confident in the number of tabs bump the 10 to 100 or so. This solution uses wtype, and allowed me to delete several hundred tmp containers in a few minutes.

@neekt
Copy link
Author

neekt commented Nov 18, 2022

Despite all the great proposed solutions in this thread, I have found that the only way to fix the bricked cloud sync issue is to delete your Firefox account and sign up again. It takes ~5-10 mins.

Steps:

  1. Go to accounts.firefox.com/settings, scroll to the bottom and 'Delete Account'. Follow the steps to delete.
  2. In Firefox, go to settings and uncheck 'Enable Container Tabs' - you'll first need to disable any extensions that require container tabs - then re-enable it. N.B. this will reset all containers back to default.
  3. Sign up again. You can sign up again using the same email address. I also strongly recommend enabling two-step authentication.
  4. IMPORTANT: Make sure you repeat step 2 for any other Firefox desktop profile BEFORE you sign in again with the new account. Otherwise you might end up with hundreds of locally stored temporary containers bricking your cloud sync again.
  5. If you want to enable container synchronization, you'll need to disable 'Automatic Mode' in the Temporary Containers extension. Otherwise, again, you might end up with hundreds of temporary containers bricking your cloud sync.

Regarding the last step; if you use "Strict" mode in Firefox's Privacy & Security settings, temporary containers aren't really necessary from a privacy perspective any more, because this mode uses dynamic first-party isolation to isolate cookies anyway. I do still use the extension to create temporary containers manually on occasion though, e.g., if I want to sign into something temporarily.

You'll also need to re-create all of your permanent containers. It's a bit of a pain, but they should all happily sync from now on.

@mitchcurtis
Copy link

The related PR that allows excluding containers from sync via regex was just merged: mozilla/multi-account-containers#2231 (comment)

So, hopefully, the next version of multi-account-containers will work flawlessly ❤️

I just checked that now to see if I could find out when it will be released, and noticed this:

mozilla/multi-account-containers#2444

We won't be able to have a fix for mozilla/multi-account-containers#2439 before 8.1.0 is released so we need to backout mozilla/multi-account-containers#2231 and mozilla/multi-account-containers#2383.

So the fix is going to be reverted? :/

@ka223
Copy link

ka223 commented Feb 20, 2023

I have countless tmp* containers from past sessions, how can I delete them?

@timonoj
Copy link

timonoj commented Feb 21, 2023 via email

@benediktms
Copy link

For anyon ethat wanst to batch delete containers, I found the UI to be extremly unhelpful especially if you want to delete 100+ containers. The easiest way I found is to just find your containers.json file and and delete the container entries there. Where this file is depends on your OS. For macOS it's: Library/Application Support/Firefox/Profiles/[RELEASE].default-release/containers.json. For linux I think it is somewhere under .mozilla/firefox/.... No idea about windows.

I'd really like to see the ability for users to whitelist containers they want to sync, and to add an option to force overwrite rremote storage from a local FF instance. Until then container sync is unfortunatly not usable.

@neekt
Copy link
Author

neekt commented Apr 15, 2023

Note for anyone commenting here that Temporary Containers is no longer maintained, due to the owner and developer of this repository, @stoically, sadly passing away in January (see issue #618 ).

@micksmix
Copy link

I wrote a Python script that can clean out containers that start with tmp. It should work cross-platform and will allow you to select the Firefox profile you want to modify: https://gist.github.com/micksmix/4548c3b724f78a930fd330fda3e30661

@serhumanos
Copy link

I use "Container Helper" addon to delete the 1064 containers named tmp*
and they are sync :(
every time I disable and reenable MAC sync, the appears again,
is there any way to MAC sync remember wich container really are in use and delete the old backed up?
(and change the config of my non-tmp* containers, color, icon, and related sites.. ie, it change everything)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.