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

ls is resarted every time the view is focused #448

Closed
AmjadHD opened this issue Nov 3, 2018 · 11 comments
Closed

ls is resarted every time the view is focused #448

AmjadHD opened this issue Nov 3, 2018 · 11 comments
Labels
Milestone

Comments

@AmjadHD
Copy link
Contributor

AmjadHD commented Nov 3, 2018

  • OS: Windows
  • Installation: git (master)

Minimal reproduction steps

  1. open a file with an ls working
  2. change the view
  3. go back to the view

Log

LSP: window 2 requests pyls for C:\Users\User\AppData\Roaming\Sublime Text 3\Packages\Code-Profiler\code_profiler.py
LSP: starting in C:\Users\User\AppData\Roaming\Sublime Text 3\Packages\Code-Profiler
LSP: starting ['pyls']
LSP:  --> initialize
LSP: window 2 added session pyls
LSP:  --> textDocument/didOpen
LSP:  --> initialized
LSP: <--  textDocument/publishDiagnostics
LSP: project path changed, ending existing sessions
LSP: unloading session pyls
LSP:  --> shutdown
LSP:  --> exit
LSP: window 2 requests lsp-tsserver for C:\Users\User\AppData\Roaming\npm\node_modules\install\install.js
LSP: starting in C:\Users\User\AppData\Roaming\Sublime Text 3\Packages\Code-Profiler
LSP: session pyls ended
LSP: clients for window 2 unloaded
LSP: starting ['lsp-tsserver.cmd']
LSP:  --> initialize
LSP: window 2 added session lsp-tsserver
LSP: LSP stream logger stopped.
LSP: LSP stdout process ended.
LSP:  --> textDocument/didOpen
LSP:  --> initialized
LSP: <--  textDocument/publishDiagnostics
LSP: project path changed, ending existing sessions
LSP: unloading session lsp-tsserver
LSP:  --> shutdown
LSP: window 2 requests pyls for C:\Users\User\AppData\Roaming\Sublime Text 3\Packages\Code-Profiler\code_profiler.py
LSP: starting in C:\Users\User\AppData\Roaming\Sublime Text 3\Packages\Code-Profiler
LSP:  --> exit
LSP: session lsp-tsserver ended
LSP: clients for window 2 unloaded
LSP: LSP stream logger stopped.
LSP: LSP stdout process ended.
LSP: starting ['pyls']
LSP:  --> initialize
LSP: window 2 added session pyls
LSP:  --> textDocument/didOpen
LSP:  --> initialized
LSP: <--  textDocument/publishDiagnostics
@rwols rwols added the bug label Nov 3, 2018
@tomv564
Copy link
Contributor

tomv564 commented Nov 4, 2018

project path changed, ending existing sessions

These two views cause LSP think your window has reopened with a different root path.
Do you have a sublime project? With how many root folders?
Can you explain how the two files relate to each other in your filesystem?

@AmjadHD
Copy link
Contributor Author

AmjadHD commented Nov 4, 2018

yes, I have a sublime project with one folder

{
	"folders":
	[
		{
			"path": "C:\\Users\\User\\AppData\\Roaming\\Sublime Text 3\\Packages\\User\\sublime-ui"
		}
	]
}

this happens wether all files are in the project or not, and not only when switching from one file to another, basically whenever the view loses focus and regains it.

@tomv564
Copy link
Contributor

tomv564 commented Nov 6, 2018

I could repro this today while fixing the Javascript syntax issue

LSP: window 2 requests lsp-tsserver for C:\Users\User\AppData\Roaming\npm\node_modules\install\install.js
LSP: starting in C:\Users\User\AppData\Roaming\Sublime Text 3\Packages\Code-Profiler

This javascript file doesn't live under your Code-Profiler folder (or sublime-ui, but I guess that's a different example). Maybe you can help narrow down if it happens with two files of the same language? Both inside the project or one outside. Or only if the other file is also another language? How many windows are you running?

@AmjadHD
Copy link
Contributor Author

AmjadHD commented Nov 7, 2018

so far i haven't get why it does that, but i changed the _end_old_session() method to show the project paths:

import sublime
...
    def _end_old_sessions(self):
        project = get_project_path(self._window)
        if project != self._project_path:
            debug('project path changed, ending existing sessions', self._project_path, ' ==> ', project)
            debug('windows: ', sublime.active_window().id(), ' ==> ', self._window.id())
            self.end_sessions()

hopefully it helps
I was able to reproduced it today and i got this:

LSP: global configs ['golsp=False', 'haskell-ide-engine=False', 'reason=False', 'polymer-ide=False', 'jdtls=True', 'julials=True', 'typescript-language-server=False', 'cquery=False', 'pyls=True', 'kotlinls=True', 'vscode-html=True', 'vscode-json=True', 'eslint=False', 'lsp-tsserver=True', 'bashls=True', 'phpls=False', 'javascript-typescript-langserver=False', 'vscode-css=True', 'rls=True', 'clangd=False', 'ocaml=False']
LSP: window 2 starting 1 initial views
LSP: window 2 requests pyls for C:\Users\User\AppData\Roaming\Sublime Text 3\Packages\LSP\plugin\core\windows.py
LSP: starting in C:\Users\User\AppData\Roaming\Sublime Text 3\Packages\LSP
LSP: starting ['pyls']
LSP:  --> initialize
LSP: window 2 added session pyls
LSP:  --> textDocument/didOpen
LSP:  --> initialized
Package Control: Skipping automatic upgrade, last run at 2018-11-07 11:43:15, next run at 2018-11-07 12:43:15 or after
LSP: closing C:\Users\User\AppData\Roaming\Sublime Text 3\Packages\LSP\plugin\core\windows.py pyls
LSP:  --> textDocument/didClose
LSP: project path changed, ending existing sessions C:\Users\User\AppData\Roaming\Sublime Text 3\Packages\LSP  ==>  C:\Users\User\Desktop\Tfach\Chrome Dino

here i sitched project from LSP to Chrome Dino

lsp: project path changed, ending existing sessions C:\Users\User\AppData\Roaming\Sublime Text 3\Packages\LSP  ==>  C:\Users\User\Desktop\Tfach\Chrome Dino
LSP: windows:  2  ==>  2
LSP: unloading session pyls
LSP:  --> shutdown
LSP:  --> exit
server: Exception in thread Thread-1:
server: Traceback (most recent call last):
server: File "c:\users\user\appdata\local\programs\python\python37\lib\threading.py", line 917, in _bootstrap_inner
server: self.run()
server: File "c:\users\user\appdata\local\programs\python\python37\lib\threading.py", line 1158, in run
server: self.function(*self.args, **self.kwargs)
server: File "c:\users\user\appdata\local\programs\python\python37\lib\site-packages\pyls\_utils.py", line 25, in run
server: return func(*args, **kwargs)
server: File "c:\users\user\appdata\local\programs\python\python37\lib\site-packages\pyls\python_ls.py", line 200, in lint
server: self.workspace.publish_diagnostics(doc_uri, flatten(self._hook('pyls_lint', doc_uri)))
server: File "c:\users\user\appdata\local\programs\python\python37\lib\site-packages\pyls\python_ls.py", line 114, in _hook
server: return hook_handlers(config=self.config, workspace=self.workspace, document=doc, **kwargs)
server: File "c:\users\user\appdata\local\programs\python\python37\lib\site-packages\pluggy\hooks.py", line 258, in __call__
server: return self._hookexec(self, self._nonwrappers + self._wrappers, kwargs)
server: File "c:\users\user\appdata\local\programs\python\python37\lib\site-packages\pluggy\manager.py", line 67, in _hookexec
server: return self._inner_hookexec(hook, methods, kwargs)
server: File "c:\users\user\appdata\local\programs\python\python37\lib\site-packages\pluggy\_tracing.py", line 82, in __call__
server: return outcome.get_result()
server: File "c:\users\user\appdata\local\programs\python\python37\lib\site-packages\pluggy\callers.py", line 76, in get_result
server: raise ex[1].with_traceback(ex[2])
server: File "c:\users\user\appdata\local\programs\python\python37\lib\site-packages\pluggy\callers.py", line 48, in from_call
server: result = func()
server: File "c:\users\user\appdata\local\programs\python\python37\lib\site-packages\pluggy\_tracing.py", line 80, in <lambda>
server: outcome = _Result.from_call(lambda: self.oldcall(hook, hook_impls, kwargs))
server: File "c:\users\user\appdata\local\programs\python\python37\lib\site-packages\pluggy\manager.py", line 61, in <lambda>
server: firstresult=hook.spec_opts.get('firstresult'),
server: File "c:\users\user\appdata\local\programs\python\python37\lib\site-packages\pluggy\callers.py", line 201, in _multicall
server: return outcome.get_result()
server: File "c:\users\user\appdata\local\programs\python\python37\lib\site-packages\pluggy\callers.py", line 76, in get_result
server: raise ex[1].with_traceback(ex[2])
server: File "c:\users\user\appdata\local\programs\python\python37\lib\site-packages\pluggy\callers.py", line 180, in _multicall
server: res = hook_impl.function(*args)
server: File "c:\users\user\appdata\local\programs\python\python37\lib\site-packages\pyls_mypy\plugin.py", line 56, in pyls_lint
server: report, errors, _ = mypy_api.run(args)
server: File "c:\users\user\appdata\local\programs\python\python37\lib\site-packages\mypy\api.py", line 54, in run
server: main(None, args=args)
server: File "c:\users\user\appdata\local\programs\python\python37\lib\site-packages\mypy\main.py", line 91, in main
server: res = type_check_only(sources, bin_dir, options, flush_errors, fscache)  # noqa
server: File "c:\users\user\appdata\local\programs\python\python37\lib\site-packages\mypy\main.py", line 148, in type_check_only
server: fscache=fscache)
server: File "c:\users\user\appdata\local\programs\python\python37\lib\site-packages\mypy\build.py", line 177, in build
server: flush_errors, fscache)
server: File "c:\users\user\appdata\local\programs\python\python37\lib\site-packages\mypy\build.py", line 350, in _build
server: graph = dispatch(sources, manager)
server: File "c:\users\user\appdata\local\programs\python\python37\lib\site-packages\mypy\build.py", line 2508, in dispatch
server: graph = load_graph(sources, manager)
server: File "c:\users\user\appdata\local\programs\python\python37\lib\site-packages\mypy\build.py", line 2702, in load_graph
server: caller_state=st, caller_line=st.dep_line_map.get(dep, 1))
server: File "c:\users\user\appdata\local\programs\python\python37\lib\site-packages\mypy\build.py", line 1843, in __init__
server: ancestor_for, root_source, skip_diagnose=temporary)
server: File "c:\users\user\appdata\local\programs\python\python37\lib\site-packages\mypy\build.py", line 2403, in find_module_and_diagnose
server: if not (options.ignore_missing_imports or in_partial_package(id, manager)):
server: File "c:\users\user\appdata\local\programs\python\python37\lib\site-packages\mypy\build.py", line 2427, in in_partial_package
server: temporary=True)
server: File "c:\users\user\appdata\local\programs\python\python37\lib\site-packages\mypy\build.py", line 1823, in __init__
server: assert id or path or source is not None, "Neither id, path nor source given"
server: AssertionError: Neither id, path nor source given
server: 
LSP: window 2 requests pyls for C:\Users\User\Desktop\Tfach\Chrome Dino\main.py
LSP: starting in C:\Users\User\Desktop\Tfach\Chrome Dino
LSP: LSP stream logger stopped.
LSP: session pyls ended
LSP: clients for window 2 unloaded
LSP: LSP stdout process ended.
LSP: starting ['pyls']
LSP:  --> initialize
LSP: window 2 added session pyls
LSP: project path changed, ending existing sessions C:\Users\User\AppData\Roaming\Sublime Text 3\Packages\LSP  ==>  C:\Users\User\Desktop\Tfach\Chrome Dino
LSP: windows:  2  ==>  2
LSP: unloading session pyls
LSP:  --> shutdown
LSP: project path changed, ending existing sessions C:\Users\User\AppData\Roaming\Sublime Text 3\Packages\LSP  ==>  C:\Users\User\Desktop\Tfach\Chrome Dino
LSP: windows:  2  ==>  2
LSP: unloading session pyls
LSP:  --> shutdown
LSP: project path changed, ending existing sessions C:\Users\User\AppData\Roaming\Sublime Text 3\Packages\LSP  ==>  C:\Users\User\Desktop\Tfach\Chrome Dino
LSP: windows:  2  ==>  2
LSP: unloading session pyls
LSP:  --> shutdown
LSP: window 2 requests lsp-tsserver for C:\Users\User\Desktop\Tfach\Chrome Dino\test.js
LSP: starting in C:\Users\User\Desktop\Tfach\Chrome Dino
LSP: starting ['lsp-tsserver.cmd']
LSP:  --> initialize
LSP: window 2 added session lsp-tsserver
LSP: project path changed, ending existing sessions C:\Users\User\AppData\Roaming\Sublime Text 3\Packages\LSP  ==>  C:\Users\User\Desktop\Tfach\Chrome Dino
LSP: windows:  2  ==>  2
LSP: unloading session lsp-tsserver
LSP:  --> shutdown
LSP: unloading session pyls
LSP:  --> shutdown
LSP: project path changed, ending existing sessions C:\Users\User\AppData\Roaming\Sublime Text 3\Packages\LSP  ==>  C:\Users\User\Desktop\Tfach\Chrome Dino
LSP: windows:  2  ==>  2
LSP: unloading session lsp-tsserver
LSP:  --> shutdown
LSP: unloading session pyls
LSP:  --> shutdown
LSP:  --> textDocument/didOpen
LSP:  --> initialized
LSP:  --> exit
LSP: session lsp-tsserver ended
Error handling server payload
Traceback (most recent call last):
  File "C:\Users\User\AppData\Roaming\Sublime Text 3\Packages\LSP\plugin\core\rpc.py", line 142, in receive_payload
    self.response_handler(payload)
  File "C:\Users\User\AppData\Roaming\Sublime Text 3\Packages\LSP\plugin\core\rpc.py", line 161, in response_handler
    self._response_handlers[handler_id](result)
  File "C:\Users\User\AppData\Roaming\Sublime Text 3\Packages\LSP\plugin\core\sessions.py", line 175, in <lambda>
    lambda result: self._handle_shutdown_result(result))
  File "C:\Users\User\AppData\Roaming\Sublime Text 3\Packages\LSP\plugin\core\sessions.py", line 178, in _handle_shutdown_result
    self.client.exit()
AttributeError: 'NoneType' object has no attribute 'exit'

server: 2018-11-07 11:47:58,914 UTC - ERROR - jsonrpc.endpoint - Failed to handle request 3
server: Traceback (most recent call last):
server: File "c:\users\user\appdata\local\programs\python\python37\lib\site-packages\jsonrpc\endpoint.py", line 178, in _handle_request
server: handler = self._dispatcher[method]
server: File "c:\users\user\appdata\local\programs\python\python37\lib\site-packages\pyls\python_ls.py", line 87, in __getitem__
server: raise KeyError
server: KeyError
server: 
server: During handling of the above exception, another exception occurred:
server: 
server: Traceback (most recent call last):
server: File "c:\users\user\appdata\local\programs\python\python37\lib\site-packages\jsonrpc\endpoint.py", line 113, in consume
server: self._handle_request(message['id'], message['method'], message.get('params'))
server: File "c:\users\user\appdata\local\programs\python\python37\lib\site-packages\jsonrpc\endpoint.py", line 180, in _handle_request
server: raise JsonRpcMethodNotFound.of(method)
server: jsonrpc.exceptions.JsonRpcMethodNotFound: Method Not Found: shutdown
server: 2018-11-07 11:47:59,092 UTC - ERROR - jsonrpc.endpoint - Failed to handle request 4
server: Traceback (most recent call last):
server: File "c:\users\user\appdata\local\programs\python\python37\lib\site-packages\jsonrpc\endpoint.py", line 178, in _handle_request
server: handler = self._dispatcher[method]
server: File "c:\users\user\appdata\local\programs\python\python37\lib\site-packages\pyls\python_ls.py", line 87, in __getitem__
server: raise KeyError
server: KeyError
server: 
server: During handling of the above exception, another exception occurred:
server: 
server: Traceback (most recent call last):
server: File "c:\users\user\appdata\local\programs\python\python37\lib\site-packages\jsonrpc\endpoint.py", line 113, in consume
server: self._handle_request(message['id'], message['method'], message.get('params'))
server: File "c:\users\user\appdata\local\programs\python\python37\lib\site-packages\jsonrpc\endpoint.py", line 180, in _handle_request
server: raise JsonRpcMethodNotFound.of(method)
server: jsonrpc.exceptions.JsonRpcMethodNotFound: Method Not Found: shutdown
server: 2018-11-07 11:47:59,269 UTC - ERROR - jsonrpc.endpoint - Failed to handle request 5
server: Traceback (most recent call last):
server: File "c:\users\user\appdata\local\programs\python\python37\lib\site-packages\jsonrpc\endpoint.py", line 178, in _handle_request
server: handler = self._dispatcher[method]
server: File "c:\users\user\appdata\local\programs\python\python37\lib\site-packages\pyls\python_ls.py", line 87, in __getitem__
server: raise KeyError
server: KeyError
server: 
server: During handling of the above exception, another exception occurred:
server: 
server: Traceback (most recent call last):
server: File "c:\users\user\appdata\local\programs\python\python37\lib\site-packages\jsonrpc\endpoint.py", line 113, in consume
server: self._handle_request(message['id'], message['method'], message.get('params'))
server: File "c:\users\user\appdata\local\programs\python\python37\lib\site-packages\jsonrpc\endpoint.py", line 180, in _handle_request
server: raise JsonRpcMethodNotFound.of(method)
server: jsonrpc.exceptions.JsonRpcMethodNotFound: Method Not Found: shutdown
server: 2018-11-07 11:47:59,447 UTC - ERROR - jsonrpc.endpoint - Failed to handle request 6
server: Traceback (most recent call last):
server: File "c:\users\user\appdata\local\programs\python\python37\lib\site-packages\jsonrpc\endpoint.py", line 178, in _handle_request
server: handler = self._dispatcher[method]
server: File "c:\users\user\appdata\local\programs\python\python37\lib\site-packages\pyls\python_ls.py", line 87, in __getitem__
server: raise KeyError
server: KeyError
server: 
server: During handling of the above exception, another exception occurred:
server: 
server: Traceback (most recent call last):
server: File "c:\users\user\appdata\local\programs\python\python37\lib\site-packages\jsonrpc\endpoint.py", line 113, in consume
server: self._handle_request(message['id'], message['method'], message.get('params'))
server: File "c:\users\user\appdata\local\programs\python\python37\lib\site-packages\jsonrpc\endpoint.py", line 180, in _handle_request
server: raise JsonRpcMethodNotFound.of(method)
server: jsonrpc.exceptions.JsonRpcMethodNotFound: Method Not Found: shutdown
LSP:  --> initialized
LSP:  --> exit
server: 2018-11-07 11:47:59,652 UTC - WARNING - jsonrpc.endpoint - Ignoring notification for unknown method initialized
LSP: session pyls ended
LSP: clients for window 2 unloaded
LSP: LSP stream logger stopped.
LSP: LSP stdout process ended.
LSP: LSP stream logger stopped.
LSP: LSP stdout process ended.
drag_select {'event': {'x': 528.5, 'y': 303.5, 'button': 1}}
was drag select
LSP: window 2 requests pyls for C:\Users\User\Desktop\Tfach\Chrome Dino\main.py
LSP: starting in C:\Users\User\Desktop\Tfach\Chrome Dino
LSP: starting ['pyls']
LSP:  --> initialize
LSP: window 2 added session pyls
LSP:  --> textDocument/didOpen
LSP:  --> initialized
LSP: <--  textDocument/publishDiagnostics
LSP: severity check 1 <= 3
LSP: project path changed, ending existing sessions C:\Users\User\AppData\Roaming\Sublime Text 3\Packages\LSP  ==>  C:\Users\User\Desktop\Tfach\Chrome Dino
LSP: windows:  2  ==>  2
LSP: unloading session pyls
LSP:  --> shutdown
LSP:  --> exit
LSP: window 2 requests pyls for C:\Users\User\Desktop\Tfach\Chrome Dino\main.py
LSP: starting in C:\Users\User\Desktop\Tfach\Chrome Dino
LSP: session pyls ended
LSP: clients for window 2 unloaded
LSP: starting ['pyls']
LSP:  --> initialize
LSP: window 2 added session pyls
LSP: LSP stream logger stopped.
LSP: LSP stdout process ended.
LSP:  --> textDocument/didOpen
LSP:  --> initialized
LSP: <--  textDocument/publishDiagnostics
LSP: severity check 1 <= 3

Observations

  1. The ls (pyls here) is complaining about something.
  2. Just a guess, I think switching from one project to another have something to do with this, anyway I think the way the project path is obtained should be revised.

@tomv564
Copy link
Contributor

tomv564 commented Nov 7, 2018

This was a pretty obvious mistake, once I realised that quick switching once could be the trigger.
I forgot to ask you this in my initial response, but I'd love to have a minimal but complete repro for bug reports in the future!

@rwols rwols added this to the Release 0.8 milestone Nov 7, 2018
@rwols
Copy link
Member

rwols commented Nov 7, 2018

This is supposed to be fixed now @AmjadHD, do you have some spare time to check this out on the latest master?

@AmjadHD
Copy link
Contributor Author

AmjadHD commented Nov 7, 2018

At first, I didn't know it has something to do with switching project, as for the issue it is fixed as the ls is no longer restarted on view focus, but it's no longer started at all (after switching):
this is the log, after switching from a project where the ls where working fine:

LSP: closing C:\Users\User\AppData\Roaming\Opera Software\Opera Stable\Extensions\ckkofollclpnogccmelmlekkcgnanphc\0.0.0.1_0\index.js lsp-tsserver
LSP:  --> textDocument/didClose
LSP: closing C:\Users\User\AppData\Roaming\npm\node_modules\eslint\lib\config.js lsp-tsserver
LSP:  --> textDocument/didClose
LSP: project path changed, ending existing sessions
LSP: new path = C:\Users\User\AppData\Roaming\Sublime Text 3\Packages\LSP
LSP: unloading session lsp-tsserver
LSP:  --> shutdown
LSP: unloading session pyls
LSP:  --> shutdown
LSP: unloading session vscode-json
LSP:  --> shutdown
LSP: invalid response payload {'result': None, 'id': 3, 'jsonrpc': '2.0'}
LSP:  --> textDocument/didOpen
LSP: invalid response payload {'result': None, 'id': 4, 'jsonrpc': '2.0'}
LSP: invalid response payload {'result': None, 'id': 2, 'jsonrpc': '2.0'}
LSP: <--  textDocument/publishDiagnostics
LSP:  --> textDocument/didOpen
server: 2018-11-07 23:20:38,299 UTC - WARNING - jsonrpc.endpoint - Ignoring notification for unknown method textDocument/didOpen
LSP: closing C:\Users\User\AppData\Roaming\Sublime Text 3\Packages\LSP\plugin\code_actions.py pyls
LSP:  --> textDocument/didClose
server: 2018-11-07 23:22:08,169 UTC - WARNING - jsonrpc.endpoint - Ignoring notification for unknown method textDocument/didClose
LSP:  --> textDocument/didOpen
server: 2018-11-07 23:22:08,348 UTC - WARNING - jsonrpc.endpoint - Ignoring notification for unknown method textDocument/didOpen

@tomv564
Copy link
Contributor

tomv564 commented Nov 9, 2018

@rwols I didn't look too closely at the changes in response_handler, but after the memory leak fix I think result: None is not being handled as an "successful but empty result" any longer (might follow the spec closer - but with pyls prevents us from sending the exit.

This means the sessions aren't removed and new sessions won't start.

@rwols
Copy link
Member

rwols commented Nov 9, 2018

Yes, my bad. I have a proposed fix for that here: #458.

@tomv564
Copy link
Contributor

tomv564 commented Nov 10, 2018

PR is merged, servers should restart now after switching project!

@AmjadHD
Copy link
Contributor Author

AmjadHD commented Nov 10, 2018

surely, thanks for fixing this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants