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
Do not expect app.getPath('userData') to be there before app.once('ready') #19662
Comments
The idea is to run in parallel to the |
This is how it used to be: var dir = path.join(app.getPath('userData'), 'CachedData');
mkdir(dir); Which is totally fine because we create the This is how @chrmarti changed it: var dir = path.join(app.getPath('userData'), 'CachedData');
mkdirp(dir); // note this mkdirP Which imho is not ok because we start to create directories all the way down until root if not existing (e.g. As such, we should move code into |
To clarify why the change was done: Before when running with a new user data dir that did not exist yet, mkdir would fail because the parent folder (the user data dir) did not exist. As a result of that no window opened, that reproduced reliably on my machine when using --user-data-dir or moving my regular user data dir to a backup location. (bug #19529) |
@chrmarti so does it reproduce if you move that code into |
No, it no longer reproduces. |
My motivation to move things before the @bpasero Is this just about us creating a folder that otherwise electron would create or about doing stuff before the ready-event? What problem do you see in us creating that folder and then electron not or vice versa? Again, there are low hanging performance improvements and more code should be moved before the ready-event. Wrt operations that read files we can also not do them; there is no backup to read without a folder, byte code caching happens only on the second start etc... Alternatively, we could refrain from creating the full path but only create the root dir if missing ( |
I see the motivation. +1 for creating the root directory but not all the directories going up. |
We decided to walk up the parent folders because there could be scenarios where users use --user-data-dir to point to a folder that needs its parent folder(s) created first. |
There is still a problem when |
Thought I had that covered. It should fail and print the associated error to the console. |
@jrieken Just see your change now. I would definitely print the error to the console, otherwise any such problem will be very hard to track down. We didn't know where the problem originated from and started with a binary search through our insiders builds to narrow down the change sets that could have caused the original problem. Then continued by looking at the diff stat and then diff between the two insider builds where it broke. Please log :) |
I generally agree but in this case it's not a problem. See, it's just an optional directory we pass on to the loader such that it can cache byte code. If that's missing everything should still work and startup can continue, it's just a little slower. Once we move more and vital things here we should handle the error properly. Now I'd rely on electron doing that |
I see, good for me then. |
There is a discussion going on in 08a1700 where @chrmarti saw an issue on startup for new users that never started Code before. I never saw this issue but the fix seems odd to me: we now suddenly create the directory (
userData
) viamkdirp
that is owned by Electron/Chrome, which seems wrong. It should be created by the framework, not us.Can we move the
getNodeCachedDataDir()
into theapp.once('ready')
callback? That is the place where all code should go that assumes a certain directory structure to be present, not before.The text was updated successfully, but these errors were encountered: