Skip to content

Commit f574838

Browse files
committed
Only trace ECONNRESET errors
... less noise, only happens outside of transactions.
1 parent 19d951c commit f574838

File tree

1 file changed

+21
-3
lines changed

1 file changed

+21
-3
lines changed

Sources/http/Server/Server.swift

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,20 @@
33
// Macro
44
//
55
// Created by Helge Hess.
6-
// Copyright © 2020-2022 ZeeZide GmbH. All rights reserved.
6+
// Copyright © 2020-2024 ZeeZide GmbH. All rights reserved.
77
//
88

9+
#if os(Linux)
10+
import let Glibc.ECONNRESET
11+
#else
12+
import let Darwin.ECONNRESET
13+
#endif
914
import class MacroCore.ErrorEmitter
1015
import enum MacroCore.EventListenerSet
1116
import class MacroCore.MacroCore
1217
import struct MacroCore.Buffer
1318
import struct Logging.Logger
19+
import struct NIOCore.IOError
1420
import struct NIO.NIOAny
1521
import class NIO.EventLoopFuture
1622
import class NIO.ServerBootstrap
@@ -538,12 +544,24 @@ open class Server: ErrorEmitter, CustomStringConvertible {
538544
// HTTPParserError.invalidEOFState
539545
server.log.error("HTTP error in TX \(id), closing connection: \(error)")
540546
server.emitError(error, transaction: ( request, response ))
547+
self.transaction = nil
541548
}
542549
else {
543-
server.log.error("HTTP error, closing connection: \(error)")
550+
assert(transaction == nil)
551+
var doError = true
552+
553+
if let error = error as? IOError, error.errnoCode == ECONNRESET {
554+
doError = false
555+
}
556+
557+
if doError {
558+
server.log.error("HTTP error, closing connection: \(error)")
559+
}
560+
else {
561+
server.log.trace("HTTP error, closing connection: \(error)")
562+
}
544563
server.emitError(error, transaction: nil)
545564
}
546-
self.transaction = nil
547565
context.close(promise: nil)
548566
}
549567
}

0 commit comments

Comments
 (0)