Skip to content

Commit ba66ebf

Browse files
committed
Remove unnecessary assertions in RedisCommandHandler
Motivation: The assertions in `errorCaught(context:error:)` and `channelRead(context:data:)` are holdovers from when SwiftLog was not integrated into the package. The conditions where they were triggered are safely handled in other ways, so the asserts are not guarding against undefined behavior or bad app state. Modifications: Remove the two asserts regarding the `RedisCommandHandler.commandResponseQueue` to rely on Logging to bubble up errors to the user. Result: Debug builds using RediStack should not encounter unexpected assertions and should rely on other, better, error handling. This contributes to issue #65
1 parent 237f049 commit ba66ebf

File tree

1 file changed

+0
-3
lines changed

1 file changed

+0
-3
lines changed

Sources/RediStack/ChannelHandlers/RedisCommandHandler.swift

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,6 @@ extension RedisCommandHandler: ChannelInboundHandler {
7676
public func errorCaught(context: ChannelHandlerContext, error: Error) {
7777
let queue = self.commandResponseQueue
7878

79-
assert(queue.count > 0, "Received unexpected error while idle: \(error.localizedDescription)")
80-
8179
self.commandResponseQueue.removeAll()
8280
queue.forEach { $0.fail(error) }
8381

@@ -95,7 +93,6 @@ extension RedisCommandHandler: ChannelInboundHandler {
9593
let value = self.unwrapInboundIn(data)
9694

9795
guard let leadPromise = self.commandResponseQueue.popFirst() else {
98-
assertionFailure("Read triggered with an empty promise queue! Ignoring: \(value)")
9996
self.logger.critical("Read triggered with no promise waiting in the queue!")
10097
return
10198
}

0 commit comments

Comments
 (0)