Skip to content

Commit

Permalink
Do not emit ECONNRESET error when there is no transaction
Browse files Browse the repository at this point in the history
It is just a long running HTTP close.
  • Loading branch information
helje5 committed Dec 20, 2024
1 parent cda8029 commit 60cb596
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions Sources/http/Server/Server.swift
Original file line number Diff line number Diff line change
Expand Up @@ -546,21 +546,17 @@ open class Server: ErrorEmitter, CustomStringConvertible {
server.emitError(error, transaction: ( request, response ))
self.transaction = nil
}
else {
else { // We are not in a transaction. ECONNRESET is not an 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)")
server.log.trace("HTTP ECONNRESET, closing connection: \(error)")
// Do not emit ECONNRESET
}
else {
server.log.trace("HTTP error, closing connection: \(error)")
server.log.error("HTTP error, closing connection: \(error)")
server.emitError(error, transaction: nil)
}
server.emitError(error, transaction: nil)
}
context.close(promise: nil)
}
Expand Down

0 comments on commit 60cb596

Please sign in to comment.