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

Do not reload file from disk on save #1278

Merged
merged 1 commit into from
Apr 25, 2022
Merged

Conversation

robertoaloi
Copy link
Member

The current version of Erlang LS reloads from disk the file on save.
Since didSave/didChange methods are notifications (i.e. handled asynchronously by the server),
the following race condition could be caused by the sequence:

SAVE -> CHANGE -> SAVE

Especially in presence of auto-save.
While the server is still processing the first SAVE, the version read from disk is the result
of the CHANGE being already applied, so the CHANGE operation could fail as invalid.

There's actually very little meaning in reloading the file from disk during save, since all
changes are sent to the server via CHANGE notifications.

The current version of Erlang LS reloads from disk the file on save.
Since didSave/didChange methods are notifications (i.e. handled asynchronously by the server),
the following race condition could be caused by the sequence:

SAVE -> CHANGE -> SAVE

Especially in presence of auto-save.
While the server is still processing the first SAVE, the version read from disk is the result
of the CHANGE being already applied, so the CHANGE operation could fail as invalid.

There's actually very little meaning in reloading the file from disk during save, since all
changes are sent to the server via CHANGE notifications.
@robertoaloi robertoaloi merged commit abdfa8c into main Apr 25, 2022
@robertoaloi robertoaloi deleted the solve-race-condition-on-save branch April 25, 2022 11:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants