Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Should assertCallingContextIsNotSuspended() only check the last stack trace element? #271

Open
saket opened this issue Oct 2, 2023 · 0 comments

Comments

@saket
Copy link

saket commented Oct 2, 2023

Exception in thread "SDK 31 Main Thread @coroutine#76" java.lang.IllegalStateException: Calling context is suspending; use a suspending method instead
	at app.cash.turbine.CoroutinesKt.assertCallingContextIsNotSuspended(coroutines.kt:67)

I received this crash because I'm using Turbine#takeItem() from a non-suspending function:

val results = Turbine<Foo>()

fun foo(): Result {
  return results.takeItem()
}

I can probably make it suspending to fix the problem, but I was wondering if assertCallingContextIsNotSuspended() should only check the last stack item instead of finding an instance of invokeSuspend in the entire call chain?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant