Skip to content

Handle removing the lsp-lock file in cases of non graceful IDE shutdown #5633

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

Closed
JoshuaBatty opened this issue Feb 19, 2024 · 0 comments · Fixed by #5676
Closed

Handle removing the lsp-lock file in cases of non graceful IDE shutdown #5633

JoshuaBatty opened this issue Feb 19, 2024 · 0 comments · Fixed by #5676
Assignees

Comments

@JoshuaBatty
Copy link
Member

This lock file was originally introduced in #5094

While it does solve the original issue in #4893 , it can lead to problems when the IDE was shutdown in a non-graceful manner, leaving behind the old lock file. This is the report from Slack:

forc fmt refuses to format claiming that some files are open in an editor. I'm using nvim. Thought it was looking for swap files but there were none, everything was saved cleanly.
Turns out the sway lsp marked the file as dirty using a file as a lock over in "$HOME/.forc/.lsp_locks" or something similar. Had to manually remove the file.
Don't know how robust the lock file removal process is in cases of a ungraceful shutdown of the sway lsp.
In any case it took some digging around the code to figure out what to remove.
Maybe it would cause less headaches going forward to lower this from a refusal to format down to a warning?

@crodas crodas self-assigned this Feb 26, 2024
crodas added a commit that referenced this issue Feb 28, 2024
Fixes #5633

Added functionality to create and manage a lock file containing the process ID
(pid) of the running instance of the software. This mechanism prevents multiple
instances of the software from running simultaneously by checking the existence
and content of the lock file. If the lock file exists and contains a valid pid,
the struct will error gracefully to avoid conflicts. If the lock file is
missing or contains an invalid pid, the struct will proceed by removing the
file.  This ensures that only one instance of the software can run at a time
and it avoids stale locking for preventing future instances

This implements an advisory mutex based on path. This mutex is advisory and
opt-in. It is a cheap way to multiple processes to avoid writing the same file
at the same time
crodas added a commit that referenced this issue Feb 28, 2024
Fixes #5633

Added functionality to create and manage a lock file containing the process ID
(pid) of the running instance of the software. This mechanism prevents multiple
instances of the software from running simultaneously by checking the existence
and content of the lock file. If the lock file exists and contains a valid pid,
the struct will error gracefully to avoid conflicts. If the lock file is
missing or contains an invalid pid, the struct will proceed by removing the
file.  This ensures that only one instance of the software can run at a time
and it avoids stale locking for preventing future instances
crodas added a commit that referenced this issue Feb 28, 2024
Fixes #5633

Added functionality to create and manage a lock file containing the process ID
(pid) of the running instance of the software. This mechanism prevents multiple
instances of the software from running simultaneously by checking the existence
and content of the lock file. If the lock file exists and contains a valid pid,
the struct will error gracefully to avoid conflicts. If the lock file is
missing or contains an invalid pid, the struct will proceed by removing the
file.  This ensures that only one instance of the software can run at a time
and it avoids stale locking to prevent future instances
@crodas crodas mentioned this issue Feb 28, 2024
7 tasks
crodas added a commit that referenced this issue Feb 28, 2024
Fixes #5633

Added functionality to create and manage a lock file containing the process ID
(pid) of the running instance of the software. This mechanism prevents multiple
instances of the software from running simultaneously by checking the existence
and content of the lock file. If the lock file exists and contains a valid pid,
the struct will error gracefully to avoid conflicts. If the lock file is
missing or contains an invalid pid, the struct will proceed by removing the
file.  This ensures that only one instance of the software can run at a time
and it avoids stale locking to prevent future instances
crodas added a commit that referenced this issue Mar 1, 2024
Fixes #5633

Added functionality to create and manage a lock file containing the process ID
(pid) of the running instance of the software. This mechanism prevents multiple
instances of the software from running simultaneously by checking the existence
and content of the lock file. If the lock file exists and contains a valid pid,
the struct will error gracefully to avoid conflicts. If the lock file is
missing or contains an invalid pid, the struct will proceed by removing the
file.  This ensures that only one instance of the software can run at a time
and it avoids stale locking to prevent future instances
crodas added a commit that referenced this issue Mar 5, 2024
Fixes #5633

Added functionality to create and manage a lock file containing the process ID
(pid) of the running instance of the software. This mechanism prevents multiple
instances of the software from running simultaneously by checking the existence
and content of the lock file. If the lock file exists and contains a valid pid,
the struct will error gracefully to avoid conflicts. If the lock file is
missing or contains an invalid pid, the struct will proceed by removing the
file.  This ensures that only one instance of the software can run at a time
and it avoids stale locking to prevent future instances
crodas added a commit that referenced this issue Mar 7, 2024
## Description

Fixes #5633

Added functionality to create and manage a lock file containing the
process ID (pid) of the running instance of the software. This mechanism
prevents multiple instances of the software from running simultaneously
by checking the existence and content of the lock file. If the lock file
exists and contains a valid pid, the struct will error gracefully to
avoid conflicts. If the lock file is missing or contains an invalid pid,
the struct will proceed by removing the file. This ensures that only one
instance of the software can run at a time and it avoids stale locking
to prevent future instances


## Checklist

- [x] I have linked to any relevant issues.
- [x] I have commented my code, particularly in hard-to-understand
areas.
- [x] I have updated the documentation where relevant (API docs, the
reference, and the Sway book).
- [x] I have added tests that prove my fix is effective or that my
feature works.
- [x] I have added (or requested a maintainer to add) the necessary
`Breaking*` or `New Feature` labels where relevant.
- [x] I have done my best to ensure that my PR adheres to [the Fuel Labs
Code Review
Standards](https://github.com/FuelLabs/rfcs/blob/master/text/code-standards/external-contributors.md).
- [x] I have requested a review from the relevant team or maintainers.
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.

2 participants