Skip to content

Sleep support for testing async delay #1106

@momoohidayat

Description

@momoohidayat

when i add try await Task.sleep() inside an async function, it will not return the console correctly

example code:

func fetchPosts() async throws -> String {
    try await Task.sleep(nanoseconds: 500_000_000) // simulate network delay
    return "Posts loaded"
}

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