Open TomLXXVI opened 2 years ago
Since recently, the bug doesn't show up anymore. I think that a recent Windows update solved the issue for me.
I have a similar error with all operating system updates. The error occurs some time after the start of work. And Lsp server stops working.
A properly escaped repeating fragment of long long stacktrace:
{"jsonrpc":"2.0","id":1190,"method":"textDocument/documentHighlight","params":{"textDocument":{"uri":"file:///c:/projects/sequence-labeling/.virtual_documents/notebooks/parse_dataset.ipynb"},"position":{"line":116,"character":40}}} Traceback (most recent call last): File "C:\Users\artif\AppData\Local\pypoetry\Cache\virtualenvs\sequence-labeling-poy5HrIU-py3.10\lib\site-packages\jupyter_lsp\stdio.py", line 193, in write await convert_yielded(self._write_one(response.encode("utf-8"))) File "C:\Scoop\apps\python\current\lib\concurrent\futures\thread.py", line 58, in run result = self.fn(*self.args, **self.kwargs) File "C:\Users\artif\AppData\Local\pypoetry\Cache\virtualenvs\sequence-labeling-poy5HrIU-py3.10\lib\site-packages\jupyter_lsp\stdio.py", line 201, in _write_one self.stream.write(message) OSError: [Errno 22] Invalid argument [E 2022-12-04 11:33:09.518 ServerApp] <LspStdIoWriter(parent=<LanguageServerSession(language_server=pylsp, argv=['C:\\Users\\xxxx\\AppData\\Local\\pypoetry\\Cache\\virtualenvs\\sequence-labeling-poy5HrIU-py3.10\\Scripts\\python.exe', '-m', 'pylsp'])>)> couldn't write message: Content-Length: 4645
Description
Recently I have created a new virtual environment with Anaconda on a Windows 11 PC, in which I installed Jupyterlab 3.4.3 together with jupyterlab-lsp and python-lsp-server. While jupyterlab is running, an error appears in the log all of the time and autocompletion etc. stops working in jupyterlab. I copied the relevant excerpt from the log below, which shows the exception that is thrown:
[E 2022-06-14 14:49:47.157 ServerApp] <LspStdIoWriter(parent=<LanguageServerSession(language_server=pylsp, argv=[‘C:\Users\Tom\anaconda3\envs\engineering-22-06\python.exe’, ‘-m’, ‘pylsp’])>)> couldn’t write message: Content-Length: 266
{"jsonrpc":"2.0","id":267,"method":"textDocument/documentHighlight","params":{"textDocument":{"uri":"file:///c:/Users/Tom/PycharmProjects/GeneralEngineering/.virtual_documents/control_systems/notebooks/mechanical_network.ipynb"},"position":{"line":2,"character":9}}} Traceback (most recent call last): File "C:\Users\Tom\anaconda3\envs\engineering-22-06\lib\site-packages\jupyter_lsp\stdio.py", line 193, in write await convert_yielded(self._write_one(response.encode("utf-8"))) File "C:\Users\Tom\anaconda3\envs\engineering-22-06\lib\asyncio\futures.py", line 284, in await yield self # This tells Task to wait for completion. File "C:\Users\Tom\anaconda3\envs\engineering-22-06\lib\asyncio\tasks.py", line 304, in __wakeup future.result() File "C:\Users\Tom\anaconda3\envs\engineering-22-06\lib\asyncio\futures.py", line 201, in result raise self._exception File "C:\Users\Tom\anaconda3\envs\engineering-22-06\lib\concurrent\futures\thread.py", line 58, in run result = self.fn(*self.args, **self.kwargs) File "C:\Users\Tom\anaconda3\envs\engineering-22-06\lib\site-packages\jupyter_lsp\stdio.py", line 201, in _write_one self.stream.write(message) OSError: [Errno 22] Invalid argument
Reproduce
I haven't found yet how to reproduce the error. As you can see in the log excerpt above, the error happens in ServerApp (so I think it has to do with jupyter-lsp) while Jupyterlab is running in the browser (server runs on localhost). As the error happened mostly when I saw in the log message that method
textDocument/documentHighlight
was called, I first tought that disabling "Code Highlights" in Jupyterlab Settings could help to stabilize the connection with the language server. However, it turned out that this is not the case. I think it is because the methodtextDocument/documentHighlight
is called frequently, changes are high that the error occurs while this method is called.I found that when I click the refresh button of the browser, the lsp-connection gets up and running again, but after a short while the error comes up again.
Expected behavior
A stable connection with the language server (without the need to click the browser's refresh button all the time).
Context
Required: installed server extensions
Required: installed lab extensions
Troubleshoot Output
Command Line Output
Browser Output (recommended for all interface issues)