Skip to content

Commit e95e6cc

Browse files
author
Loïc Mangeonjean
committed
fix: force dispose connection on shutdown
1 parent 5c55513 commit e95e6cc

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

src/createLanguageClient.ts

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,25 @@ async function createLanguageClient (
125125
return undefined
126126
}
127127

128-
const client = new MonacoLanguageClient({
128+
// Hack to force close the connection when the language client stops
129+
// Even if the `shutdown` request failed
130+
class _MonacoLanguageClient extends MonacoLanguageClient {
131+
override async stop (timeout: number): Promise<void> {
132+
// eslint-disable-next-line dot-notation
133+
const connection = this['_connection']
134+
try {
135+
await super.stop(timeout)
136+
} finally {
137+
try {
138+
connection.dispose()
139+
} catch (err) {
140+
// ignore
141+
}
142+
}
143+
}
144+
}
145+
146+
const client = new _MonacoLanguageClient({
129147
id: `${id}-languageclient`,
130148
name: `CodinGame ${id} Language Client`,
131149
clientOptions: {

0 commit comments

Comments
 (0)