airbnb / mavericks

Mavericks: Android on Autopilot
https://airbnb.io/mavericks/
Apache License 2.0
5.83k stars 500 forks source link

Ensure that your state properties properly implement hashCode. #604

Closed pengzee closed 2 years ago

pengzee commented 2 years ago

java.lang.IllegalArgumentException: Impure reducer set on VerifyPasswordViewModel! verifyTime changed from 1641982584320 to 1641982584321. Ensure that your state properties properly implement hashCode. at com.airbnb.mvrx.MavericksViewModel$setState$1.invoke(MavericksViewModel.kt:134) at com.airbnb.mvrx.MavericksViewModel$setState$1.invoke(MavericksViewModel.kt:117) at com.airbnb.mvrx.CoroutinesStateStore$flushQueuesOnce$2$1.invokeSuspend(CoroutinesStateStore.kt:84) at com.airbnb.mvrx.CoroutinesStateStore$flushQueuesOnce$2$1.invoke(Unknown Source:8) at com.airbnb.mvrx.CoroutinesStateStore$flushQueuesOnce$2$1.invoke(Unknown Source:4) at kotlinx.coroutines.intrinsics.UndispatchedKt.startCoroutineUnintercepted(Undispatched.kt:30) at kotlinx.coroutines.channels.AbstractChannel.tryStartBlockUnintercepted(AbstractChannel.kt:783) at kotlinx.coroutines.channels.AbstractChannel.registerSelectReceiveMode(AbstractChannel.kt:760) at kotlinx.coroutines.channels.AbstractChannel.access$registerSelectReceiveMode(AbstractChannel.kt:515) at kotlinx.coroutines.channels.AbstractChannel$onReceive$1.registerSelectClause1(AbstractChannel.kt:737) at kotlinx.coroutines.selects.SelectBuilderImpl.invoke(Select.kt:634) at com.airbnb.mvrx.CoroutinesStateStore.flushQueuesOnce(CoroutinesStateStore.kt:83) at com.airbnb.mvrx.CoroutinesStateStore.access$flushQueuesOnce(CoroutinesStateStore.kt:18) at com.airbnb.mvrx.CoroutinesStateStore$setupTriggerFlushQueues$1.invokeSuspend(CoroutinesStateStore.kt:59) at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33) at kotlinx.coroutines.selects.SelectBuilderImpl.resumeWith(Select.kt:302) at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:46) at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106) 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:764)


When the method setState{} invoked several times in a short time, the method changes a long type of MavericksState, and then a crash occurs

elihart commented 2 years ago

yes, it's telling you that you are doing something wrong Impure reducer set on VerifyPasswordViewModel! verifyTime changed

elihart commented 2 years ago

you are probably calculating the value inside the reducer lambda which is not allowed. it must be pure ie constant