mirror of
https://github.com/swift-server/RediStack.git
synced 2026-05-03 07:32:28 +00:00
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
This commit is contained in:
@@ -76,8 +76,6 @@ extension RedisCommandHandler: ChannelInboundHandler {
|
||||
public func errorCaught(context: ChannelHandlerContext, error: Error) {
|
||||
let queue = self.commandResponseQueue
|
||||
|
||||
assert(queue.count > 0, "Received unexpected error while idle: \(error.localizedDescription)")
|
||||
|
||||
self.commandResponseQueue.removeAll()
|
||||
queue.forEach { $0.fail(error) }
|
||||
|
||||
@@ -95,7 +93,6 @@ extension RedisCommandHandler: ChannelInboundHandler {
|
||||
let value = self.unwrapInboundIn(data)
|
||||
|
||||
guard let leadPromise = self.commandResponseQueue.popFirst() else {
|
||||
assertionFailure("Read triggered with an empty promise queue! Ignoring: \(value)")
|
||||
self.logger.critical("Read triggered with no promise waiting in the queue!")
|
||||
return
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user