Issues with Async/Await in Ember application code


Recently on the Slack channel it was flagged that Ember application code has some issues with using async/await syntax, with it not being properly wrapped in the runloop.

I seem to be using it throughout the application (in services, actions, etc) with no issues.

I wondered if this forum was a good place to document known edge cases and where we might come unstuck. Even better if we have an idea on where getting these issues resolved lay in the priority list.


@JonForest there’s some good info about why async/await currently has some limitations in Readers’ Questions: “Why does Ember still use RSVP?”


My understanding is that if your app code uses async/await then it’s possible to create a situation where your tests fail with the autorun error:

You have turned on testing mode, which disabled the run-loop’s autorun. You will need to wrap any code with asynchronous side-effects in a run.

If you run into this, a possible fix could be wrapping code that comes after await in an function, but that adds a bit of boiler plate.

Instead of using async/await in services or actions I’ve been using Ember concurrency tasks. I’ve found that it has the same mental model for thinking about asynchronous code, but also has the added benefit of EC’s lifecycle guarantees.


This has been well documented and discussed.