Skip to content

Commit 8fdf274

Browse files
Eduardo Perezkylebrowning
authored andcommitted
Fixed bug:
When the connection fails, responsePromise get's deallocated (deinit is called) without being fulfilled. This causes a fatal error in debug: "fatalError("leaking promise created at \(creation)", file: creation.file, line: creation.line)", file EventLoopFuture.swift. The case is that when flatMap fails, there's no path in which the promise get's fulfilled. This solution fulfills the promise, even if nothing is done with it.
1 parent 2cd3cfd commit 8fdf274

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

Sources/NIOAPNS/APNSConnection.swift

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,10 +80,12 @@ public final class APNSConnection {
8080
request: buffer,
8181
responsePromise: responsePromise
8282
)
83+
8384
return streamPromise.futureResult.flatMap { stream in
84-
stream.writeAndFlush(context)
85-
}.flatMap {
86-
responsePromise.futureResult
85+
responsePromise.futureResult.whenComplete { _ in }
86+
return stream.writeAndFlush(context)
87+
}.flatMap {
88+
responsePromise.futureResult
8789
}
8890
}
8991

0 commit comments

Comments
 (0)