Skip to content

Commit 7a3d19d

Browse files
authored
Don't log misleading errors when the client closes a connection (#585)
1 parent ce59628 commit 7a3d19d

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

Sources/PostgresNIO/New/PostgresChannelHandler.swift

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -567,8 +567,13 @@ final class PostgresChannelHandler: ChannelDuplexHandler {
567567
_ cleanup: ConnectionStateMachine.ConnectionAction.CleanUpContext,
568568
context: ChannelHandlerContext
569569
) {
570-
self.logger.debug("Cleaning up and closing connection.", metadata: [.error: "\(cleanup.error)"])
571-
570+
// Don't log a misleading error if the client closed the connection.
571+
if cleanup.error.code == .clientClosedConnection {
572+
self.logger.debug("Cleaning up and closing connection.")
573+
} else {
574+
self.logger.debug("Cleaning up and closing connection.", metadata: [.error: "\(cleanup.error)"])
575+
}
576+
572577
// 1. fail all tasks
573578
cleanup.tasks.forEach { task in
574579
task.failWithError(cleanup.error)

0 commit comments

Comments
 (0)