Skip to content

Multiple language servers get started (and terminated) if vim is started with vim -p #878

@TysonAndre

Description

@TysonAndre
  • Did you upgrade to latest plugin version? yes
  • Did you upgrade to/compile latest binary? languageclient 0.1.147

Describe the bug

Multiple php language servers are started up on vim startup when vim opens multiple php files with vim -p. This requires a lot of memory to initialize (causes swapping if there are dozens of files), and all but one don't end up being used

I believe this is a race condition in src/language_server_protocol.rs in languageClient_startServer.

The project that I'm editing with vim is very large, so the language server takes more than a second to respond to the language server initialize RPC request

        if self.get(|state| state.clients.contains_key(&Some(languageId.clone())))? {
            return Ok(json!({}));
        }
// much, much later, without a mutex getting acquired globally or for the language id
        self.update(|state| {
            state.clients.insert(Some(languageId.clone()), client);
            Ok(())
        })?;

Environment

To Reproduce

Steps to reproduce the behavior:

  1. Set up phan for a large project and install the language server
  2. Start vim, vim -p file1.php file2.php file3.php file4.php
  3. ps -ef|grep -i php. Observe that initially, multiple language servers are running, but afterwards, there are defunct php processes with the bin/languageclient as the parent process.

Current behavior

Multiple php language servers are started up on vim startup when vim opens multiple php files with vim -p. This requires a lot of memory to initialize (causes swapping if there are dozens of files), and all but one don't end up being used

Expected behavior

A single php language server is started up (i.e. one per language, or one per server command in the future)

Screenshots

If applicable, add screenshots to help explain your problem.

Additional context

Add any other context about the problem here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions