Skip to content

A replaced start attempt can still clear serverError and install its connection after initialize #1863

Closed

Description

@lagergren

Since #1673 and #1827, a start() while a restart attempt initializes returns, and the start task stops a provider whose attempt a stop or a newer start replaced before the provider was made. One window is left: the stages of the start chain after initServer don't check that their attempt is still the current one:

  1. the stage that sets serverError = null, serverCapabilities and the client features' capabilities;
  2. the stage that sends initialized;
  3. the stage that installs the attempt's lspStreamProvider, languageClient, languageServer and launcherFuture into the wrapper and calls updateStatus(ServerStatus.started).

stop() cancels only initializeFuture, the chain's last stage, the exceptionally one. So for an attempt that a stop, or a stop and a newer start, replaced after it sent initialize, these stages still run when its reply comes: the old attempt clears the error that the current attempt is restarting for, sets the capabilities from its own server, and installs its connection, whose provider stop() is shutting down, over the current one, with the status started.

We saw what the whole race does with 0.21.0. After a server's process was killed, eight processes started within 0.33 s; two of them initialized and served the project at once, the document's didOpen going to one and the feature requests for it to the other, and one was never stopped. main fixes the first two causes; this is what remains.

A proposal: a check, in stages 1 and 3 and under the wrapper's monitor for stage 3, that throws a CancellationException unless the attempt is still currentInitializingContext and the wrapper isn't disposed. The attempt's own exceptionally stage is cancelled already, so it reports nothing.

Seen in main (1988ab6c), with the Ecstasy language server (XVM).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions