Skip to content

cancelOnGracefulShutdown never returns #135

Closed
@sliemeobn

Description

@sliemeobn

In version 2.0.0-alpha.1

swift-driver version: 1.75.2 Apple Swift version 5.8 (swiftlang-5.8.0.124.2 clang-1403.0.22.11.100)
Target: arm64-apple-macosx13.0

Calling cancelOnGracefulShutdown currently never finishes, because the withThrowingTaskGroup keeps running the "waiting-for-graceful-shutdown" task.

Afaik this is due to some unfortunate inconsistency with task groups with their "cancelAll on return" behavior.
edit: this has nothing to do with environment or inconsistencies, was just a plain bug.

This test will never finish in my environment:

    func testResumesCancelOnGracefulShutdownWithResult() async throws {
        await testGracefulShutdown { _ in
            let result = await cancelOnGracefulShutdown {
                await Task.yield()
                return "hello"
            }

            XCTAssertEqual(result, "hello")
        }
    }

Adding a "manual" group.cancelAll() should do the trick.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions