duytq94 / flutter-chat-demo

The chat app made by Flutter and Firebase
MIT License
1.76k stars 676 forks source link

A transaction object cannot be used after its update callback has been invoked. #39

Closed wann2 closed 4 years ago

wann2 commented 4 years ago

Very good demo!

When I send a chat message, I got the below error.

java.lang.RuntimeException: An error occurred while executing doInBackground() at android.os.AsyncTask$4.done(AsyncTask.java:399) at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:383) at java.util.concurrent.FutureTask.setException(FutureTask.java:252) at java.util.concurrent.FutureTask.run(FutureTask.java:271) at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:289) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641) at java.lang.Thread.run(Thread.java:919)

Caused by: java.lang.AssertionError: INTERNAL ASSERTION FAILED: A transaction object cannot be used after its update callback has been invoked. at com.google.firebase.firestore.util.Assert.fail(com.google.firebase:firebase-firestore@@21.3.0:46) at com.google.firebase.firestore.util.Assert.hardAssert(com.google.firebase:firebase-firestore@@21.3.0:31) at com.google.firebase.firestore.core.Transaction.ensureCommitNotCalled(com.google.firebase:firebase-firestore@@21.3.0:246) at com.google.firebase.firestore.core.Transaction.write(com.google.firebase:firebase-firestore@@21.3.0:241) at com.google.firebase.firestore.core.Transaction.set(com.google.firebase:firebase-firestore@@21.3.0:105) at com.google.firebase.firestore.Transaction.set(com.google.firebase:firebase-firestore@@21.3.0:91) at com.google.firebase.firestore.Transaction.set(com.google.firebase:firebase-firestore@@21.3.0:67) at io.flutter.plugins.firebase.cloudfirestore.CloudFirestorePlugin$7.doInBackground(CloudFirestorePlugin.java:688) at io.flutter.plugins.firebase.cloudfirestore.CloudFirestorePlugin$7.doInBackground(CloudFirestorePlugin.java:682) at android.os.AsyncTask$3.call(AsyncTask.java:378) at java.util.concurrent.FutureTask.run(FutureTask.java:266) at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:289)  at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)  at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)  at java.lang.Thread.run(Thread.java:919) 

duytq94 commented 4 years ago

I just test it and everything fine when sending some messages on both iOS and Android. Seem this is a cloud_firestore bug described here FirebaseExtended/flutterfire#1969 when the internet is slow.

wann2 commented 4 years ago

Something might be wrong inside the downloaded sources. I have changed it into my app packages environment, at first everything works fine, but after I executed as your extended push notification guide and then from that time it seemed to be go wrong. Your codes are very exciting to me, but I think It seems to be very hard work to resolve sending message problem.

duytq94 commented 4 years ago

I haven't clear detail your cases, but if you clone the source code and open it by Android Studio, get packages and then run as normal with nothing wrong happen (I also tested with new clone).

wann2 commented 4 years ago

Thanks for kind guide, I will do the steps from the first after deleting all.