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

resolve race condition of get_buffer_content trying to read file content before handle_open_file finished #999

Merged
merged 2 commits into from
Jul 26, 2024

Conversation

nohzafk
Copy link
Contributor

@nohzafk nohzafk commented Jul 26, 2024

Testing lsp-bridge in container gives me more edge case

This error happens constantly, get_buffer_content is trying to read file content before handle_open_file finished, when it happens, lsp stops working, that's why I'm having trouble using language server inside container.

We need to wrap the file access opeartion with lock to ensure the access is atomatic.

error log

Traceback (most recent call last):
  File "/tmp/lsp-bridge/lsp_bridge.py", line 625, in event_dispatcher
    getattr(self, func_name)(*func_args)
  File "/tmp/lsp-bridge/lsp_bridge.py", line 886, in _do
    action.call(name, *args)
  File "/nix/store/f8ki1wxp84nj1nldjlj50y5wm5qknyn9-lsp-bridge-src-20240717-master/core/fileaction.py", line 166, in call
    getattr(self, method)(*args, **kwargs)
  File "/nix/store/f8ki1wxp84nj1nldjlj50y5wm5qknyn9-lsp-bridge-src-20240717-master/core/fileaction.py", line 191, in change_file
    buffer_content = get_buffer_content(self.filepath, buffer_name)
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/nix/store/f8ki1wxp84nj1nldjlj50y5wm5qknyn9-lsp-bridge-src-20240717-master/core/utils.py", line 129, in get_buffer_content
    return lsp_bridge_server.file_server.file_dict[filename]
           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^
KeyError: '/workspaces/the_gleam_learner/test/flat_tensor_test.gleam'

With this change, the error no long happen, and language server works good, close #997

@manateelazycat manateelazycat merged commit cd0a08d into manateelazycat:master Jul 26, 2024
1 check passed
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.

basedpyright_ruff issue
2 participants