# \#asyncawait

**URL:** https://forums.swift.org/tag/asyncawait/490.md

[Latest](https://forums.swift.org/latest.md) · [Categories](https://forums.swift.org/categories.md) · [Tags](https://forums.swift.org/tags.md)

---

## [Streaming chat completions in plain Swift with URLSession.bytes (no SDK)](https://forums.swift.org/t/streaming-chat-completions-in-plain-swift-with-urlsession-bytes-no-sdk/90133)

<div class="topic-metadata">

**Author:** [@apigoto2026](https://forums.swift.org/u/apigoto2026)\
**Replies:** 0\
**Last updated:** [October 18, 2026, 2:01pm UTC](https://forums.swift.org/t/streaming-chat-completions-in-plain-swift-with-urlsession-bytes-no-sdk/90133 "2026-10-18T14:01:22Z")

</div>

Most LLM APIs now speak the same "OpenAI-style" HTTP protocol. You don't need a package for it: URLSession.bytes(for:) plus AsyncLineSequence handles the server-sent-event stream in about 40 lines. Here is the version I …

---

## [How to make a blocking call from a sync func to an async func](https://forums.swift.org/t/how-to-make-a-blocking-call-from-a-sync-func-to-an-async-func/86935)

<div class="topic-metadata">

**Author:** [@snej](https://forums.swift.org/u/snej)\
**Replies:** 26\
**Last updated:** [May 28, 2026, 9:09am UTC](https://forums.swift.org/t/how-to-make-a-blocking-call-from-a-sync-func-to-an-async-func/86935 "2026-05-28T09:09:51Z")

</div>

:fire: I am fully aware that what I am asking here is a grave sin. :fire: However: TL;DR: Is there any supported way to call an async function from a non-async one, blocking the calling thread (yea, verily!) until the c…

---

## [\`override\` functions behaves differently in \`async\` and \`throws\`](https://forums.swift.org/t/override-functions-behaves-differently-in-async-and-throws/83998)

<div class="topic-metadata">

**Author:** [@akuzminskyi](https://forums.swift.org/u/akuzminskyi)\
**Replies:** 17\
**Last updated:** [April 8, 2026, 9:42pm UTC](https://forums.swift.org/t/override-functions-behaves-differently-in-async-and-throws/83998 "2026-04-08T21:42:14Z")

</div>

Hi, I have a such sample code class A { func funcAsync() async { print("a: async") } func funcThrows() throws { print("a: throws") } } class B: A { override func funcAsync() async { …

---

## [SIGABRT freed pointer was not the last allocation crash](https://forums.swift.org/t/sigabrt-freed-pointer-was-not-the-last-allocation-crash/78772)

<div class="topic-metadata">

**Author:** [@proft](https://forums.swift.org/u/proft)\
**Replies:** 3\
**Last updated:** [April 2, 2026, 2:31pm UTC](https://forums.swift.org/t/sigabrt-freed-pointer-was-not-the-last-allocation-crash/78772 "2026-04-02T14:31:30Z")

</div>

Hello Swift Community, I have following wierd behaviour with async let Task { for workout in items { // Crash on Xcode 16.2 Swift 6.0.3 async let result1 = workout.getStrokeCount() …

---

## [Swift-async-collections](https://forums.swift.org/t/swift-async-collections/85312)

<div class="topic-metadata">

**Author:** [@SerhanAksut](https://forums.swift.org/u/SerhanAksut)\
**Replies:** 1\
**Last updated:** [March 13, 2026, 8:10am UTC](https://forums.swift.org/t/swift-async-collections/85312 "2026-03-13T08:10:08Z")

</div>

Hi everyone, I'd like to share AsyncCollections - a lightweight package that adds async and concurrent higher-order functions to Swift's Sequence type. Motivation Running async work over a regular Array typically mean…

---

## [\[AsyncAlgorithms\] FlatMapLatest algorithm](https://forums.swift.org/t/asyncalgorithms-flatmaplatest-algorithm/84404)

<div class="topic-metadata">

**Author:** [@Philippe\_Hausler](https://forums.swift.org/u/Philippe_Hausler)\
**Replies:** 10\
**Last updated:** [March 8, 2026, 12:48am UTC](https://forums.swift.org/t/asyncalgorithms-flatmaplatest-algorithm/84404 "2026-03-08T00:48:36Z")

</div>

The flatMapLatest (also known as switchToLatest) are commonly requested algorithms for AsyncSequence; this proposal adds that functionality. Previously it was discussed in the pre-pitch here: PrePitch: Introduce \`(flat)…

---

## [TaskGroup and Tasks memory consumption](https://forums.swift.org/t/taskgroup-and-tasks-memory-consumption/84772)

<div class="topic-metadata">

**Author:** [@CFUsername](https://forums.swift.org/u/CFUsername)\
**Replies:** 17\
**Last updated:** [February 19, 2026, 11:17am UTC](https://forums.swift.org/t/taskgroup-and-tasks-memory-consumption/84772 "2026-02-19T11:17:54Z")

</div>

I was recently reading following blog post How Much Memory Do You Need to Run 1 Million Concurrent Tasks? | Piotr Kołaczkowski , and wondered how would Swift's TaskGroup compare. I have created a small snippet and run i…

---

## [Cannot use \`?\` with async?](https://forums.swift.org/t/cannot-use-with-async/69963)

<div class="topic-metadata">

**Author:** [@wadetregaskis](https://forums.swift.org/u/wadetregaskis)\
**Replies:** 2\
**Last updated:** [February 15, 2026, 3:05pm UTC](https://forums.swift.org/t/cannot-use-with-async/69963 "2026-02-15T15:05:17Z")

</div>

let nonAsyncLocalVariable: \[Int\]? = \[\] func throwingAsyncFunc() async throws -\> \[Int\] { \[\] } let x = try await nonAsyncLocalVariable ?? throwingAsyncFunc() wot.swift:7:44: error: 'async' call in an autoclosure th…

---

## [\[Pitch\] \`withTimeout\` method](https://forums.swift.org/t/pitch-withtimeout-method/84447)

<div class="topic-metadata">

**Author:** [@FranzBusch](https://forums.swift.org/u/FranzBusch)\
**Replies:** 46\
**Last updated:** [February 10, 2026, 5:18pm UTC](https://forums.swift.org/t/pitch-withtimeout-method/84447 "2026-02-10T17:18:36Z")

</div>

Hey everyone, I have drafted up a pitch proposal for swift-async-algorithms to introduce a new withTimeout method. You can find the whole pitch here Introduction This proposal introduces withTimeout, a function that e…

---

## [\#SendingRisksDataRace errors when turning on NonisolatedNonsendingByDefault](https://forums.swift.org/t/sendingrisksdatarace-errors-when-turning-on-nonisolatednonsendingbydefault/84589)

<div class="topic-metadata">

**Author:** [@Cyberbeni](https://forums.swift.org/u/Cyberbeni)\
**Replies:** 2\
**Last updated:** [February 6, 2026, 3:30am UTC](https://forums.swift.org/t/sendingrisksdatarace-errors-when-turning-on-nonisolatednonsendingbydefault/84589 "2026-02-06T03:30:29Z")

</div>

I am using Swift 6.2.3 on Linux with // swift-tools-version:6.2. When I turn on NonisolatedNonsendingByDefault then the following code: private extension HTML { consuming func render(into buffer: UnsafeMutablePointer\<B…

---

## [@MainActor conflict with async UseCase in SwiftUI ViewModel](https://forums.swift.org/t/mainactor-conflict-with-async-usecase-in-swiftui-viewmodel/79461)

<div class="topic-metadata">

**Author:** [@imany](https://forums.swift.org/u/imany)\
**Replies:** 10\
**Last updated:** [January 28, 2026, 8:10am UTC](https://forums.swift.org/t/mainactor-conflict-with-async-usecase-in-swiftui-viewmodel/79461 "2026-01-28T08:10:46Z")

</div>

I’m getting a data-race warning in my ProductViewModel : "Sending main actor-isolated 'self.getProductsUseCase' to nonisolated callee risks causing data races" @MainActor class ProductViewModel: ObservableObject { …

---

## [Is @concurrent now the standard tool for shifting expensive synchronous work off the main actor?](https://forums.swift.org/t/is-concurrent-now-the-standard-tool-for-shifting-expensive-synchronous-work-off-the-main-actor/82976)

<div class="topic-metadata">

**Author:** [@jeremyabannister](https://forums.swift.org/u/jeremyabannister)\
**Replies:** 44\
**Last updated:** [January 8, 2026, 9:13am UTC](https://forums.swift.org/t/is-concurrent-now-the-standard-tool-for-shifting-expensive-synchronous-work-off-the-main-actor/82976 "2026-01-08T09:13:06Z")

</div>

I reached for the new @concurrent attribute for the first time just now, and I want to verify that my understanding is correct and that I'm not missing a different recommended way to handle my situation. I'm writing a m…

---

## [Different behaviour on adding explicit actor isolation to \`group.addTask\`](https://forums.swift.org/t/different-behaviour-on-adding-explicit-actor-isolation-to-group-addtask/83822)

<div class="topic-metadata">

**Author:** [@soumyamahunt](https://forums.swift.org/u/soumyamahunt)\
**Replies:** 4\
**Last updated:** [December 24, 2025, 6:11am UTC](https://forums.swift.org/t/different-behaviour-on-adding-explicit-actor-isolation-to-group-addtask/83822 "2025-12-24T06:11:40Z")

</div>

Hi, I am running into an use-case where I am seeing different behaviour if I add global actor isolation explicitly to group.addTask. I have declared an actor with custom executor like this: class SerialDispatchExecutor:…

---

## [@MainActor needs precondition to run on main actor?](https://forums.swift.org/t/mainactor-needs-precondition-to-run-on-main-actor/83588)

<div class="topic-metadata">

**Author:** [@realmtai](https://forums.swift.org/u/realmtai)\
**Replies:** 3\
**Last updated:** [December 6, 2025, 3:22pm UTC](https://forums.swift.org/t/mainactor-needs-precondition-to-run-on-main-actor/83588 "2025-12-06T15:22:56Z")

</div>

Hello folks, Does @MainActor need some sort of precondition to run on the main actor? I have an app intent with a perform method. The codebase is fully Swift6 with strict concurrency. It compiles and runs great. Howeve…

---

## [Async-friendly read-write lock](https://forums.swift.org/t/async-friendly-read-write-lock/67987)

<div class="topic-metadata">

**Author:** [@Nickolas\_Pohilets](https://forums.swift.org/u/Nickolas_Pohilets)\
**Replies:** 24\
**Last updated:** [November 25, 2025, 8:30pm UTC](https://forums.swift.org/t/async-friendly-read-write-lock/67987 "2025-11-25T20:30:19Z")

</div>

I’m looking for a library that implements async/await-friendly read-write lock. I.e., the one which stores continuations instead of blocking threads. Any recommendations? Do custom executors allow this?

---

## [Async await how to async let void functions?](https://forums.swift.org/t/async-await-how-to-async-let-void-functions/58653)

<div class="topic-metadata">

**Author:** [@Reckoned](https://forums.swift.org/u/Reckoned)\
**Replies:** 8\
**Last updated:** [November 19, 2025, 8:12am UTC](https://forums.swift.org/t/async-await-how-to-async-let-void-functions/58653 "2025-11-19T08:12:01Z")

</div>

I want to be able to call multiple void functions in parallel. How do you call a let async on a void functions? for functions that return an item its easy async let games = getGames() func getGames() async -\> Games { …

---

## [withCheckedThrowingContinuation and typed Errors](https://forums.swift.org/t/withcheckedthrowingcontinuation-and-typed-errors/72502)

<div class="topic-metadata">

**Author:** [@filiplazov](https://forums.swift.org/u/filiplazov)\
**Replies:** 6\
**Last updated:** [October 24, 2025, 10:37am UTC](https://forums.swift.org/t/withcheckedthrowingcontinuation-and-typed-errors/72502 "2025-10-24T10:37:48Z")

</div>

Hello Folks I am experimenting with the new typed errors, and kinda hit a challenge, and that is in particular with withCheckedThrowingContinuation. It uses any Error which is opposite to the specific error I want to us…

---

## [Unexpected UIApplication behavior under Swift Concurrency](https://forums.swift.org/t/unexpected-uiapplication-behavior-under-swift-concurrency/82160)

<div class="topic-metadata">

**Author:** [@TimofeiKarpovR](https://forums.swift.org/u/TimofeiKarpovR)\
**Replies:** 10\
**Last updated:** [September 17, 2025, 6:26pm UTC](https://forums.swift.org/t/unexpected-uiapplication-behavior-under-swift-concurrency/82160 "2025-09-17T18:26:07Z")

</div>

Hello, Calling UIApplication from a non-main-actor context triggers Main Thread Checker at runtime. Code sample: class ViewController: UIViewController { override func viewDidLoad() { super.viewDidLoad() …

---

## [Question about using \`withoutActuallyEscaping\` and \`withCheckedContinuation\` together](https://forums.swift.org/t/question-about-using-withoutactuallyescaping-and-withcheckedcontinuation-together/81974)

<div class="topic-metadata">

**Author:** [@Serika\_PHB](https://forums.swift.org/u/Serika_PHB)\
**Replies:** 5\
**Last updated:** [September 8, 2025, 6:54am UTC](https://forums.swift.org/t/question-about-using-withoutactuallyescaping-and-withcheckedcontinuation-together/81974 "2025-09-08T06:54:19Z")

</div>

When using withoutActuallyEscaping together with withCheckedContinuation in the following codes, I still occasionally get the runtime error “closure argument was escaped in withoutActuallyEscaping block“ func run\<R: Sen…

---

## [Automatically convert C++ methods taking a completion block to async?](https://forums.swift.org/t/automatically-convert-c-methods-taking-a-completion-block-to-async/81527)

<div class="topic-metadata">

**Author:** [@tomhamming](https://forums.swift.org/u/tomhamming)\
**Replies:** 2\
**Last updated:** [August 29, 2025, 2:11pm UTC](https://forums.swift.org/t/automatically-convert-c-methods-taking-a-completion-block-to-async/81527 "2025-08-29T14:11:56Z")

</div>

If I have this Objective-C class: @interface Foo : NSObject -(void)requestURL:(NSString \*)url completion:(void (^)(NSData \* \_Nullable))completion; @end It automatically gets exposed to Swift so I can call it like this: …

---

## [CancellationError](https://forums.swift.org/t/cancellationerror/60009)

<div class="topic-metadata">

**Author:** [@somu](https://forums.swift.org/u/somu)\
**Replies:** 9\
**Last updated:** [August 22, 2025, 2:48pm UTC](https://forums.swift.org/t/cancellationerror/60009 "2025-08-22T14:48:49Z")

</div>

Overview: I have a function that makes an async request to download some content using the below mentioned code When setup(from:) is cancelled it doesn't throw CancellationError Instead it throws Error Domain=NSURLError…

---

## [Calling synchronous function with async let](https://forums.swift.org/t/calling-synchronous-function-with-async-let/59211)

<div class="topic-metadata">

**Author:** [@seanmrich](https://forums.swift.org/u/seanmrich)\
**Replies:** 8\
**Last updated:** [August 13, 2025, 4:11pm UTC](https://forums.swift.org/t/calling-synchronous-function-with-async-let/59211 "2025-08-13T16:11:17Z")

</div>

I have two methods that I'd like to run in parallel. One is synchronous and the other asynchronous. This seems like an obvious target for an async let declaration like this one: async let a = synchronous() async let b =…

---

## [Task or Detached Task or DispatchQueue](https://forums.swift.org/t/task-or-detached-task-or-dispatchqueue/81619)

<div class="topic-metadata">

**Author:** [@vykut](https://forums.swift.org/u/vykut)\
**Replies:** 3\
**Last updated:** [August 13, 2025, 12:54am UTC](https://forums.swift.org/t/task-or-detached-task-or-dispatchqueue/81619 "2025-08-13T00:54:16Z")

</div>

Hello, I have such code, that is converting async/ await code to completion-based code (for backwards compatibility purposes). final class Repository { func fetchData() async throws -\> Data { // simulate network …

---

## [Unexpected Deinit not on the MainActor](https://forums.swift.org/t/unexpected-deinit-not-on-the-mainactor/81599)

<div class="topic-metadata">

**Author:** [@vykut](https://forums.swift.org/u/vykut)\
**Replies:** 1\
**Last updated:** [August 11, 2025, 9:26pm UTC](https://forums.swift.org/t/unexpected-deinit-not-on-the-mainactor/81599 "2025-08-11T21:26:23Z")

</div>

Hi, I find it very surprising that code referenced inside a @MainActor closure can be deallocated on a different thread. I have the following bare minimum reproducible example of the issue that I’m facing import Found…

---

## [@isolated(any) isolation property is nil for non global actor isolation](https://forums.swift.org/t/isolated-any-isolation-property-is-nil-for-non-global-actor-isolation/79310)

<div class="topic-metadata">

**Author:** [@MuniekMg](https://forums.swift.org/u/MuniekMg)\
**Replies:** 11\
**Last updated:** [August 5, 2025, 2:44am UTC](https://forums.swift.org/t/isolated-any-isolation-property-is-nil-for-non-global-actor-isolation/79310 "2025-08-05T02:44:19Z")

</div>

Hi, I'm experimenting with the @isolated(any) attribute on functions introduced in SE-0431. If I understand it correctly, closures annotated with @isolated(any) should carry isolation (Actor reference) from the context …

---

## [Unsafe actor access](https://forums.swift.org/t/unsafe-actor-access/80985)

<div class="topic-metadata">

**Author:** [@soumyamahunt](https://forums.swift.org/u/soumyamahunt)\
**Replies:** 0\
**Last updated:** [July 8, 2025, 3:46pm UTC](https://forums.swift.org/t/unsafe-actor-access/80985 "2025-07-08T15:46:41Z")

</div>

Currently when migrating code to concurrency code that should be isolated to GlobalActor can be marked @preconcurrency @GlobalActor to avoid breaking existing code. @globalActor actor MyGlobalActor: GlobalActor { st…

---

## [Do async operations always run on a background thread?](https://forums.swift.org/t/do-async-operations-always-run-on-a-background-thread/80484)

<div class="topic-metadata">

**Author:** [@danmihai](https://forums.swift.org/u/danmihai)\
**Replies:** 37\
**Last updated:** [July 4, 2025, 4:32pm UTC](https://forums.swift.org/t/do-async-operations-always-run-on-a-background-thread/80484 "2025-07-04T16:32:26Z")

</div>

In trying to clarify async/await for myself. I'm just wondering, when you await how do you know/program it to run on a background thread as opposed to the main thread – if that even makes sense. Coming from other platfo…

---

## [Closure + actor + task](https://forums.swift.org/t/closure-actor-task/80223)

<div class="topic-metadata">

**Author:** [@NicolasL](https://forums.swift.org/u/NicolasL)\
**Replies:** 4\
**Last updated:** [June 5, 2025, 12:19pm UTC](https://forums.swift.org/t/closure-actor-task/80223 "2025-06-05T12:19:38Z")

</div>

Hello I am sorry it's me again :) I have new questions on async/await and actor I have my actor that look like this, really simple actor MyActor { var value: Int = 0 } so if I try to modify my value from a closure …

---

## [Why do Task executions appear ordered inside an actor even when priorities differ?](https://forums.swift.org/t/why-do-task-executions-appear-ordered-inside-an-actor-even-when-priorities-differ/80182)

<div class="topic-metadata">

**Author:** [@NicolasL](https://forums.swift.org/u/NicolasL)\
**Replies:** 15\
**Last updated:** [May 30, 2025, 8:44am UTC](https://forums.swift.org/t/why-do-task-executions-appear-ordered-inside-an-actor-even-when-priorities-differ/80182 "2025-05-30T08:44:40Z")

</div>

I've been experimenting with Swift Concurrency and noticed an interesting behavior. If I write the following code inside an actor: actor MyActor { func runTasks() { for i in 0..\<100 { let priori…

---

## [A Command-Line Tool with CoreHID & Async / Await -- how to enumerate devices up-front / once?](https://forums.swift.org/t/a-command-line-tool-with-corehid-async-await-how-to-enumerate-devices-up-front-once/79697)

<div class="topic-metadata">

**Author:** [@maven](https://forums.swift.org/u/maven)\
**Replies:** 2\
**Last updated:** [May 7, 2025, 10:48am UTC](https://forums.swift.org/t/a-command-line-tool-with-corehid-async-await-how-to-enumerate-devices-up-front-once/79697 "2025-05-07T10:48:09Z")

</div>

I'm probably missing something really basic here: I'm using CoreHID to interact with HID devices, and I want to have a command-line tool that interacts with some particular devices. In order to enumerate the devices of…

[Next page](https://forums.swift.org/tag/asyncawait/490.md?match_all_tags=true&page=1&tags%5B%5D=asyncawait)
