TypeFox / monaco-components

Monaco Editor and Language Client Wrapper, plus Monaco Editor React Component
MIT License
42 stars 13 forks source link

Worker Leaks if Language Client Fails to Start #41

Closed montymxb closed 1 year ago

montymxb commented 1 year ago

This pertains to the MonacoEditorLanguageClientWrapper when using a worker for the language server.

When starting the wrapper up, if the languageClientWrapper internally fails to start for some reason (such as when working with a misconfigured LS), it's possible to get the LC stuck in a 'starting' state. In such a case disposing of the wrapper, which has failed to start, will also fail because the language client cannot be cleaned up. Due to the order of execution for cleanup on dispose, this means the worker for the language server (if using a worker & not a WS) can be leaked during dispose.

We should ensure that the worker is always cleaned up upon dispose, even if the language client fails on being disposed itself.