{"action":"created","issue":{"url":"https://api.github.com/repos/atom/electron/issues/2493","labels_url":"https://api.github.com/repos/atom/electron/issues/2493/labels{/name}","comments_url":"https://api.github.com/repos/atom/electron/issues/2493/comments","events_url":"https://api.github.com/repos/atom/electron/issues/2493/events","html_url":"https://github.com/atom/electron/issues/2493","id":100701111,"number":2493,"title":"Multipe instances of an Electron app have problems with localStorage ","user":{"login":"duanyao","id":1684137,"avatar_url":"https://avatars.githubusercontent.com/u/1684137?v=3","gravatar_id":"","url":"https://api.github.com/users/duanyao","html_url":"https://github.com/duanyao","followers_url":"https://api.github.com/users/duanyao/followers","following_url":"https://api.github.com/users/duanyao/following{/other_user}","gists_url":"https://api.github.com/users/duanyao/gists{/gist_id}","starred_url":"https://api.github.com/users/duanyao/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/duanyao/subscriptions","organizations_url":"https://api.github.com/users/duanyao/orgs","repos_url":"https://api.github.com/users/duanyao/repos","events_url":"https://api.github.com/users/duanyao/events{/privacy}","received_events_url":"https://api.github.com/users/duanyao/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":5,"created_at":"2015-08-13T06:42:42Z","updated_at":"2015-08-15T03:20:34Z","closed_at":null,"body":"If we start multipe instances of an Electron app, they will have problems with localStorage:\r\n\r\n* One instance can not see the change to the localStorage made by another one during its lifetime.\r\n\r\n* `storage` event is not fired after another instance made change to the localStorage.\r\n\r\n* If two instances make changes to a same key, the last change win (becomes persistent) after all of them exit.\r\n\r\nI think this problem, as well as #2483, make multipe instance mode of electron very dangerous. I think Electron should officially ban multipe instance mode untils these problems are solved, or users' data are in risk.\r\n\r\nTested with 0.30.4-win32 on Win7 64bit.\r\n"},"comment":{"url":"https://api.github.com/repos/atom/electron/issues/comments/131287079","html_url":"https://github.com/atom/electron/issues/2493#issuecomment-131287079","issue_url":"https://api.github.com/repos/atom/electron/issues/2493","id":131287079,"user":{"login":"duanyao","id":1684137,"avatar_url":"https://avatars.githubusercontent.com/u/1684137?v=3","gravatar_id":"","url":"https://api.github.com/users/duanyao","html_url":"https://github.com/duanyao","followers_url":"https://api.github.com/users/duanyao/followers","following_url":"https://api.github.com/users/duanyao/following{/other_user}","gists_url":"https://api.github.com/users/duanyao/gists{/gist_id}","starred_url":"https://api.github.com/users/duanyao/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/duanyao/subscriptions","organizations_url":"https://api.github.com/users/duanyao/orgs","repos_url":"https://api.github.com/users/duanyao/repos","events_url":"https://api.github.com/users/duanyao/events{/privacy}","received_events_url":"https://api.github.com/users/duanyao/received_events","type":"User","site_admin":false},"created_at":"2015-08-15T03:20:34Z","updated_at":"2015-08-15T03:20:34Z","body":"@etiktin \r\n>When the application loads, it checks if there's another instance. If there isn't it loads the business logic. If there is, it will notify the other instance and exit. The other instance will open a new window for your app so it will appear like you have 2 instances running. \r\n\r\nYeah, this is what I'm doing now. If this is the only way to safely use localStorage etc. in Electron, shouldn't Electron make it default, or at least provides a API/config option to do so? However in #648, Electron team asked developers to do it themselves, which made me thought that multi-instance mode is safe and supported.\r\n\r\n>But the last change wins, isn't (that's exactly how localStorage is designed to work).\r\n\r\nYes, but other instances can't see the change and just assumes they have won (imaging a text editor which saves files in localStorage). If Electron can't make localStorage work as expected in multi-instance mode, I think it's better to make localStorage's API throw for following instances.\r\n"}}