Skip to content

Commit cff8607

Browse files
committed
fix: prevent error on dispose
1 parent dd549f3 commit cff8607

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

src/LanguageClient.tsx

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -116,11 +116,15 @@ function LanguageClient ({
116116
// eslint-disable-next-line no-console
117117
console.info('Shutting down language server')
118118
clearTimeout(startTimeout)
119-
languageClient.dispose().then(() => {
120-
// eslint-disable-next-line no-console
121-
console.info('Language server shut down')
122-
}, err => {
123-
console.error('Unable to dispose language client', err)
119+
setTimeout(() => {
120+
// Close in a timeout so the languageclient is not disposed at the exact same time as a model
121+
// Or a error is displayed because it fails to send the didClose notification
122+
languageClient.dispose().then(() => {
123+
// eslint-disable-next-line no-console
124+
console.info('Language server shut down')
125+
}, err => {
126+
console.error('Unable to dispose language client', err)
127+
})
124128
})
125129
}
126130
}, [id, counter, shouldShutdownLanguageClientForInactivity, onError, onDidChangeStatus, onWillShutdown, infrastructure, clientOptions, clientManagerOptions, shouldShutdownLanguageClientAsNotActiveTab])

0 commit comments

Comments
 (0)