Skip to content

Commit

Permalink
Only trace ECONNRESET errors
Browse files Browse the repository at this point in the history
... less noise, only happens outside of transactions.
  • Loading branch information
helje5 committed Oct 8, 2024
1 parent 19d951c commit f574838
Showing 1 changed file with 21 additions and 3 deletions.
24 changes: 21 additions & 3 deletions Sources/http/Server/Server.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,20 @@
// Macro
//
// Created by Helge Hess.
// Copyright © 2020-2022 ZeeZide GmbH. All rights reserved.
// Copyright © 2020-2024 ZeeZide GmbH. All rights reserved.
//

#if os(Linux)
import let Glibc.ECONNRESET
#else
import let Darwin.ECONNRESET
#endif
import class MacroCore.ErrorEmitter
import enum MacroCore.EventListenerSet
import class MacroCore.MacroCore
import struct MacroCore.Buffer
import struct Logging.Logger
import struct NIOCore.IOError
import struct NIO.NIOAny
import class NIO.EventLoopFuture
import class NIO.ServerBootstrap
Expand Down Expand Up @@ -538,12 +544,24 @@ open class Server: ErrorEmitter, CustomStringConvertible {
// HTTPParserError.invalidEOFState
server.log.error("HTTP error in TX \(id), closing connection: \(error)")
server.emitError(error, transaction: ( request, response ))
self.transaction = nil
}
else {
server.log.error("HTTP error, closing connection: \(error)")
assert(transaction == nil)
var doError = true

if let error = error as? IOError, error.errnoCode == ECONNRESET {
doError = false
}

if doError {
server.log.error("HTTP error, closing connection: \(error)")
}
else {
server.log.trace("HTTP error, closing connection: \(error)")
}
server.emitError(error, transaction: nil)
}
self.transaction = nil
context.close(promise: nil)
}
}
Expand Down

0 comments on commit f574838

Please sign in to comment.