swift-nio-extras icon indicating copy to clipboard operation
swift-nio-extras copied to clipboard

`QuiescingHelper` init & forget will crash your program

Open weissi opened this issue 2 years ago • 1 comments

https://github.com/apple/swift-nio-extras/blob/a75e92bde3683241c15df3dd905b7a6dcac4d551/Sources/NIOExtras/QuiescingHelper.swift#L229

If you create a new QuiescingHelper() but then end up not using it, it'll crash your program for a leaked promise. There's probably a better solution for that. If it should remain the API contract we can probably give the user a better message than the leaked promise?

weissi avatar Jul 04 '22 16:07 weissi

Hmm, the API contract absolutely requires that you call makeServerChannelHandler exactly once. We can probably enforce that constraint using an atomic bool or a lock.

Lukasa avatar Jul 04 '22 16:07 Lukasa