Skip to content

Commit a43337c

Browse files
glbrnttMrMage
authored andcommitted
Upgrade swift-nio to 1.12
1 parent 78c5fed commit a43337c

File tree

2 files changed

+13
-8
lines changed

2 files changed

+13
-8
lines changed

Package.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ var packageDependencies: [Package.Dependency] = [
2121
.package(url: "https://github.com/apple/swift-protobuf.git", .upToNextMinor(from: "1.1.1")),
2222
.package(url: "https://github.com/kylef/Commander.git", .upToNextMinor(from: "0.8.0")),
2323
.package(url: "https://github.com/apple/swift-nio-zlib-support.git", .upToNextMinor(from: "1.0.0")),
24-
.package(url: "https://github.com/apple/swift-nio.git", .upToNextMinor(from: "1.11.0")),
24+
.package(url: "https://github.com/apple/swift-nio.git", .upToNextMinor(from: "1.12.0")),
2525
.package(url: "https://github.com/apple/swift-nio-nghttp2-support.git", .upToNextMinor(from: "1.0.0")),
2626
.package(url: "https://github.com/apple/swift-nio-http2.git", .revision("dd9339e6310ad8537a271f3ff60a4f3976ca8e4d"))
2727
]

Sources/SwiftGRPCNIO/GRPCChannelHandler.swift

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -55,15 +55,20 @@ extension GRPCChannelHandler: ChannelInboundHandler {
5555
return
5656
}
5757

58-
var responseHeaders = HTTPHeaders()
59-
responseHeaders.add(name: "content-type", value: "application/grpc")
60-
ctx.write(self.wrapOutboundOut(.headers(responseHeaders)), promise: nil)
61-
6258
let codec = callHandler.makeGRPCServerCodec()
59+
let handlerRemoved: EventLoopPromise<Bool> = ctx.eventLoop.newPromise()
60+
handlerRemoved.futureResult.whenSuccess { handlerWasRemoved in
61+
assert(handlerWasRemoved)
62+
63+
ctx.pipeline.add(handler: callHandler, after: codec).whenComplete {
64+
var responseHeaders = HTTPHeaders()
65+
responseHeaders.add(name: "content-type", value: "application/grpc")
66+
ctx.write(self.wrapOutboundOut(.headers(responseHeaders)), promise: nil)
67+
}
68+
}
69+
6370
ctx.pipeline.add(handler: codec, after: self)
64-
.then { ctx.pipeline.add(handler: callHandler, after: codec) }
65-
//! FIXME(lukasa): Fix the ordering of this with NIO 1.12 and replace with `remove(, promise:)`.
66-
.whenComplete { _ = ctx.pipeline.remove(handler: self) }
71+
.whenComplete { ctx.pipeline.remove(handler: self, promise: handlerRemoved) }
6772

6873
case .message, .end:
6974
preconditionFailure("received \(requestPart), should have been removed as a handler at this point")

0 commit comments

Comments
 (0)