Skip to content

Commit dd95a3d

Browse files
authored
Merge pull request #1738 from ahoppen/pop-outstanding-request-on-crash
Remove elements from `outstandingRequests` on crash
2 parents dcafaa9 + e50b4d7 commit dd95a3d

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

Sources/LanguageServerProtocolJSONRPC/JSONRPCConnection.swift

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -172,13 +172,14 @@ public final class JSONRPCConnection: Connection {
172172
)
173173

174174
ioGroup.notify(queue: queue) { [weak self] in
175-
guard let self = self else { return }
175+
guard let self else { return }
176+
for outstandingRequest in self.outstandingRequests.values {
177+
outstandingRequest.replyHandler(LSPResult.failure(ResponseError.internalError("JSON-RPC Connection closed")))
178+
}
179+
self.outstandingRequests = [:]
180+
self.receiveHandler = nil // break retain cycle
176181
Task {
177-
for outstandingRequest in self.outstandingRequests.values {
178-
outstandingRequest.replyHandler(LSPResult.failure(ResponseError.internalError("JSON-RPC Connection closed")))
179-
}
180182
await self.closeHandler?()
181-
self.receiveHandler = nil // break retain cycle
182183
}
183184
}
184185

0 commit comments

Comments
 (0)