swift-server/swift-service-lifecycle

Question: return type of `cancelOnGracefulShutdown`

sidepelican opened this issue · 1 comments

public func cancelOnGracefulShutdown<T: Sendable>(_ operation: @Sendable @escaping () async throws -> T) async rethrows -> T? {

I noticed that the cancelOnGracefulShutdown method signature suggests it returns an optional (T?).
However, I couldn’t find any code paths in the implementation where a nil value would be returned.

Could you please clarify why the return type is optional in this context?
Is there a scenario where this method might return nil that I might have missed?

You are right this seems like a mistake we should fix. This method indeed shouldn't return an optional. Would you be open to work on a PR for this?