Skip to content

Commit ea16fc3

Browse files
committed
improvement: pass down file/line in makeFutureWithTask
In some circumstances it can be difficult to know which specific call to makeFutureWithTask leaked a promise. Passes through file/line to help aid debugging such situations.
1 parent 447b281 commit ea16fc3

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

Diff for: Sources/NIOCore/AsyncAwaitSupport.swift

+6-2
Original file line numberDiff line numberDiff line change
@@ -339,8 +339,12 @@ struct AsyncSequenceFromIterator<AsyncIterator: AsyncIteratorProtocol>: AsyncSeq
339339
@available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *)
340340
extension EventLoop {
341341
@inlinable
342-
public func makeFutureWithTask<Return>(_ body: @Sendable @escaping () async throws -> Return) -> EventLoopFuture<Return> {
343-
let promise = self.makePromise(of: Return.self)
342+
public func makeFutureWithTask<Return>(
343+
file: StaticString = #fileID,
344+
line: UInt = #line,
345+
_ body: @Sendable @escaping () async throws -> Return
346+
) -> EventLoopFuture<Return> {
347+
let promise = self.makePromise(of: Return.self, file: file, line: line)
344348
promise.completeWithTask(body)
345349
return promise.futureResult
346350
}

0 commit comments

Comments
 (0)