Skip to content

Commit d9ea155

Browse files
authored
Merge pull request #1612 from ahoppen/log-cancellation-singpost-event
Log a signpost event when a request is cancelled
2 parents ae152de + 6d5e95f commit d9ea155

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

Sources/SourceKitLSP/SourceKitLSPServer.swift

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -617,8 +617,12 @@ extension SourceKitLSPServer: MessageHandler {
617617
// See comment in `withLoggingScope`.
618618
// The last 2 digits should be sufficient to differentiate between multiple concurrently running requests.
619619
await withLoggingScope("request-\(id.numericValue % 100)") {
620-
await self.handleImpl(params, id: id, reply: reply)
621-
signposter.endInterval("Request", state, "Done")
620+
await withTaskCancellationHandler {
621+
await self.handleImpl(params, id: id, reply: reply)
622+
signposter.endInterval("Request", state, "Done")
623+
} onCancel: {
624+
signposter.emitEvent("Cancelled", id: signpostID)
625+
}
622626
}
623627
// We have handled the request and can't cancel it anymore.
624628
// Stop keeping track of it to free the memory.

0 commit comments

Comments
 (0)