From ecfaa2c6ff3234bdf7909eba0da01c245922e471 Mon Sep 17 00:00:00 2001 From: Johannes Weiss Date: Mon, 16 Dec 2024 08:32:23 +0000 Subject: [PATCH] fix bogus "unleakable promise leaked" error message (#2855) (#3027) ### Motivation: SwiftNIO contained a bogus error message: ``` BUG in SwiftNIO (please report), unleakable promise leaked.:486: Fatal error: leaking promise created at (file: "BUG in SwiftNIO (please report), unleakable promise leaked.", line: 486) ``` The actual meaning is that the ELG was shut down prematurely. ### Modifications: - Replace the message with an accurate one ### Result: - Users less confused - fixes #2855 - fixes #2201 --- Sources/NIOCore/EventLoopFuture.swift | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Sources/NIOCore/EventLoopFuture.swift b/Sources/NIOCore/EventLoopFuture.swift index 793d3a7ed5..4579576ed6 100644 --- a/Sources/NIOCore/EventLoopFuture.swift +++ b/Sources/NIOCore/EventLoopFuture.swift @@ -163,7 +163,12 @@ public struct EventLoopPromise { internal static func makeUnleakablePromise(eventLoop: EventLoop, line: UInt = #line) -> EventLoopPromise { EventLoopPromise( eventLoop: eventLoop, - file: "BUG in SwiftNIO (please report), unleakable promise leaked.", + file: """ + EventLoopGroup shut down with unfulfilled promises remaining. \ + This suggests that the EventLoopGroup was shut down with unfinished work outstanding which is \ + illegal. Either switch to using the singleton EventLoopGroups or fix the issue by only shutting down \ + the EventLoopGroups when all the work associated with them has finished. + """, line: line ) }