realm-swift: Exception with error: "Cannot schedule async transaction. Make sure you are running from inside a run loop."

Problem

When trying to perform an async write from within a thread without a run-loop, which is a common situation when performing an async write in a Task, an exception happens with the following error:

Cannot schedule async transaction. Make sure you are running from inside a run loop.

  1. This is missing from the documentation
  2. Is this limitation going to be lifted in the future?

Solution

No response

How important is this improvement for you?

Would be a major improvement

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Reactions: 13
  • Comments: 18 (3 by maintainers)

Most upvoted comments

Any news on this? This is blocking me too right now

Any update on this please?

Any news?

This is an ongoing project at the moment, we’ve been improving concurrency support in our last releases, but there some things which are still on the works. We’ll let you know when this is working correctly.

Current update is that we are enabling Actor confined Realm’s in the near future. I know it is not exactly what is being asked for here, but technically accomplishes the same end result. Once a Realm is confined to the Actor, you will be able to do asyncWrites on it, and we/the swift concurrency runtime will handle the rest.

Looking forward to this

Any update?