-
Notifications
You must be signed in to change notification settings - Fork 30.1k
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
Revisit introduction of mainLockfile
#128366
Comments
Actually, given we already put a Still, to be entirely sure the instance was not crashing leaving this file around, you would probably have to check the file contents and do similar logic as Alex had to implement, otherwise it would only be a guess. |
I think it is safe to make this async. It just increases the risk of race if the file is written and the process is shut down before the lifecycle handler is registered, but this risk is present regardless.
Yea, this is an inherent nature of lockfiles. Even the posix native flock(2) doesn't remove the file on process shutdown. That's why the PID is written in the lockfile, and why there's a "debug anyway" option on the dialog that js-debug presents. (In js-debug I haven't implemented logic to double check if the process ID is still running, but I could do so pretty easily if the need arises.)
This involves writing VS Code-specific logic into the generic js-debug that duplicates the name-generation process that VS Code does. In the current state we still look for a For the same reason I would rather avoid doing the workspace storage scanning in js-debug, but at least that is slightly less dependent on details like how the pipe name is formed, so I would be a little happier with that solution. However, ultimately we just want to know if there is a main process running from this user data dir, so I think having a lockfile is the cleaner option all around. |
Please don't take a dependency on the |
I've been getting lots of errors saying something like "Cannot debug because an existing debug session was found" in past couple weeks, I assume because of this. I also find it unexpected that deleting |
Can you grab a gif of this?
The new profile directory used for debugging is in the |
That's somewhat expected if OSS is torn down or killed ungracefully. While, while we're developing on it, tends to happen. The main process PID is written to the lockfile, but I don't do a liveness check on that yet. It's on my todo, but you can safely debug anyway if you think that happens. |
I've made a change so that the lock file is acquired asynchronously which should address the startup time concern. |
I am still not convinced we need to invent our own lock file though. For example, doing a Other than that, I am sure there is a file Chrome creates for locking (possibly for their various Index DBs on disk) which maybe we could probe on? |
That's where the difference lies. Named pipes on Windows are created in a global namespace so we create the name by hashing information about the VS Code version. As far as I can tell on windows there isn't a "readdir" that works on |
Nothing changed here right? Besides, once we are adopting |
Ok, I'll keep this open to track that, then. |
Depends on #97626 |
We closed this issue because we don't plan to address it in the foreseeable future. If you disagree and feel that this issue is crucial: we are happy to listen and to reconsider. If you wonder what we are up to, please see our roadmap and issue reporting guidelines. Thanks for your understanding, and happy coding! |
It looks like recently a
mainLockfile
was added to signal whether a user data dir is in use or not (126218b). I see numerous issues with that:lifecycleMainService.onWillShutdown
is ever called, the application might crash leaving a stale lock file around (cc @alexdima who just implemented a locking solution that avoids these kind of issues for the extension host state process via b1b44a3)I don't really understand why the existing IPC socket cannot be used to figure out if an instance is running? The IPC handle is statically computed based on some properties that can all be determined by reading
package.json
and orproduct.json
:vscode/src/vs/platform/environment/electron-main/environmentMainService.ts
Line 54 in 126218b
I hope we can find a different solution for this.
The text was updated successfully, but these errors were encountered: