Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.Sign up
Make Glean init in Kotlin fully async #672
I tested this both using Fenix and the Glean SDK sample app: this seem to work as expected. Accumulated data is correctly accounted for and any pre-init dispatched piece of information is sent.
This PR additionally fixes some weird bugs we had in our testing code that made our tests hang forever under certain circumstances. Se the indivudual commit messages.
Our test code relies on `withTimeout*` and `while(true)` in a few places to wait for things to happen. However, having a timeout is not enough: if the coroutine is busy, even if the timeout elapses, the work will not be interrupted. That's because cancellation in Kotlin coroutines is cooperative, see [the docs](https://github.com/Kotlin/kotlinx.coroutines/blob/master/docs/cancellation-and-timeouts.md#cancellation-is-cooperative) for more details. This commit uses cooperative cancellation so that tests will break, instead of hanging forever.