Skip to content

Commit

Permalink
Merge pull request #1738 from ahoppen/pop-outstanding-request-on-crash
Browse files Browse the repository at this point in the history
Remove elements from `outstandingRequests` on crash
  • Loading branch information
ahoppen authored Oct 7, 2024
2 parents dcafaa9 + e50b4d7 commit dd95a3d
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions Sources/LanguageServerProtocolJSONRPC/JSONRPCConnection.swift
Original file line number Diff line number Diff line change
Expand Up @@ -172,13 +172,14 @@ public final class JSONRPCConnection: Connection {
)

ioGroup.notify(queue: queue) { [weak self] in
guard let self = self else { return }
guard let self else { return }
for outstandingRequest in self.outstandingRequests.values {
outstandingRequest.replyHandler(LSPResult.failure(ResponseError.internalError("JSON-RPC Connection closed")))
}
self.outstandingRequests = [:]
self.receiveHandler = nil // break retain cycle
Task {
for outstandingRequest in self.outstandingRequests.values {
outstandingRequest.replyHandler(LSPResult.failure(ResponseError.internalError("JSON-RPC Connection closed")))
}
await self.closeHandler?()
self.receiveHandler = nil // break retain cycle
}
}

Expand Down

0 comments on commit dd95a3d

Please sign in to comment.