-
-
Notifications
You must be signed in to change notification settings - Fork 360
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
Cannot access database on the main thread #487
Comments
I'm getting the error as above |
Please update your issue with our bug report template. A sample code would also be helpful. From your stack trace it looks like you are closing the response on the main thread (which might mean that it is also read on the main thread). You can fix it by processing/closing the response on a background thread and posting the result to the main thread. As for the solution in the library it could be solved with a custom executor that processes results. I mentioned it in the next steps of #267. Although, to be perfectly honest, I'm not sure if we should change it just for this reason. Closing response on the main thread is not the best thing. It might require synchronisation and other work which can block the main thread even without |
How does your Rx chain look like? |
I had the same issue, spent a long time trying to get this and other packages working, finally figured out that I need to use the sonatype snapshot version. |
Readme isn't a place to track issues and changes. There is the changelog for that type of stuff. We do mention snapshot versions in the readme, though. |
I mean that you should mention that if there are problems experienced, try the snapshot version.Thanks ---- On Mon, 18 Apr 2022 11:54:58 -0400 ***@***.*** wrote ----
Readme isn't a place to track issues and changes. There is the changelog for that type of stuff. We do mention snapshot versions in the changelog, though.
—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you commented.Message ID: ***@***.***>
|
Exception: java.lang.IllegalStateException
java.lang.IllegalStateException: Cannot access database on the main thread since it may potentially lock the UI for a long period of time.
at androidx.room.RoomDatabase.assertNotMainThread(RoomDatabase.java:267)
at androidx.room.RoomDatabase.beginTransaction(RoomDatabase.java:351)
at com.chuckerteam.chucker.internal.data.room.HttpTransactionDao_Impl.update(HttpTransactionDao_Impl.java:345)
at com.chuckerteam.chucker.internal.data.repository.HttpTransactionDatabaseRepository.updateTransaction(HttpTransactionDatabaseRepository.kt:37)
at com.chuckerteam.chucker.api.ChuckerCollector.onResponseReceived$com_github_ChuckerTeam_Chucker_library(ChuckerCollector.kt:71)
at com.chuckerteam.chucker.api.ChuckerInterceptor$ChuckerTransactionTeeCallback.onSuccess(ChuckerInterceptor.kt:242)
at com.chuckerteam.chucker.internal.support.TeeSource.close(TeeSource.kt:69)
at okio.RealBufferedSource.close(RealBufferedSource.kt:477)
at okio.ForwardingSource.close(ForwardingSource.kt:34)
at okio.RealBufferedSource.close(RealBufferedSource.kt:477)
at okio.RealBufferedSource$inputStream$1.close(RealBufferedSource.kt:170)
kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:56)
at android.os.Handler.handleCallback(Handler.java:914)
at android.os.Handler.dispatchMessage(Handler.java:100)
at android.os.Looper.loop(Looper.java:224)
at android.app.ActivityThread.main(ActivityThread.java:7560)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:539)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:950)
The text was updated successfully, but these errors were encountered: