relaycorp / awala-endpoint-android

High-level library for Android apps implementing Awala endpoints
Apache License 2.0
2 stars 1 forks source link

Throw helpful exception when `receiveMessages()` is called before creating a first-party endpoint #335

Closed gnarea closed 12 months ago

gnarea commented 1 year ago

What happens today isn't very helpful:

2023-09-11 13:34:15.345 15347-15373 AndroidRuntime          tech.relaycorp.letro                 E  FATAL EXCEPTION: DefaultDispatcher-worker-5
                                                                                                    Process: tech.relaycorp.letro, PID: 15347
                                                                                                    tech.relaycorp.relaynet.bindings.pdc.NonceSignerException: At least one nonce signer must be specified
                                                                                                        at tech.relaycorp.poweb.PoWebClient$collectParcels$2.invokeSuspend(PoWebClient.kt:191)
                                                                                                        at tech.relaycorp.poweb.PoWebClient$collectParcels$2.invoke(Unknown Source:8)
                                                                                                        at tech.relaycorp.poweb.PoWebClient$collectParcels$2.invoke(Unknown Source:4)
                                                                                                        at kotlinx.coroutines.flow.SafeFlow.collectSafely(Builders.kt:61)
                                                                                                        at kotlinx.coroutines.flow.AbstractFlow.collect(Flow.kt:230)
                                                                                                        at tech.relaycorp.awaladroid.messaging.ReceiveMessages$collectParcels$$inlined$mapNotNull$1.collect(SafeCollector.common.kt:114)
                                                                                                        at kotlinx.coroutines.flow.FlowKt__EmittersKt$onCompletion$$inlined$unsafeFlow$1.collect(SafeCollector.common.kt:115)
                                                                                                        at kotlinx.coroutines.flow.FlowKt__CollectKt.emitAll(Collect.kt:109)
                                                                                                        at kotlinx.coroutines.flow.FlowKt.emitAll(Unknown Source:1)
                                                                                                        at tech.relaycorp.awaladroid.messaging.ReceiveMessages$receive$$inlined$flatMapLatest$1.invokeSuspend(Merge.kt:193)
                                                                                                        at tech.relaycorp.awaladroid.messaging.ReceiveMessages$receive$$inlined$flatMapLatest$1.invoke(Unknown Source:13)
                                                                                                        at tech.relaycorp.awaladroid.messaging.ReceiveMessages$receive$$inlined$flatMapLatest$1.invoke(Unknown Source:4)
                                                                                                        at kotlinx.coroutines.flow.internal.ChannelFlowTransformLatest$flowCollect$3$1$2.invokeSuspend(Merge.kt:34)
                                                                                                        at kotlinx.coroutines.flow.internal.ChannelFlowTransformLatest$flowCollect$3$1$2.invoke(Unknown Source:8)
                                                                                                        at kotlinx.coroutines.flow.internal.ChannelFlowTransformLatest$flowCollect$3$1$2.invoke(Unknown Source:4)
                                                                                                        at kotlinx.coroutines.intrinsics.UndispatchedKt.startCoroutineUndispatched(Undispatched.kt:44)
                                                                                                        at kotlinx.coroutines.CoroutineStart.invoke(CoroutineStart.kt:112)
                                                                                                        at kotlinx.coroutines.AbstractCoroutine.start(AbstractCoroutine.kt:126)
                                                                                                        at kotlinx.coroutines.BuildersKt__Builders_commonKt.launch(Builders.common.kt:56)
                                                                                                        at kotlinx.coroutines.BuildersKt.launch(Unknown Source:1)
                                                                                                        at kotlinx.coroutines.BuildersKt__Builders_commonKt.launch$default(Builders.common.kt:47)
                                                                                                        at kotlinx.coroutines.BuildersKt.launch$default(Unknown Source:1)
                                                                                                        at kotlinx.coroutines.flow.internal.ChannelFlowTransformLatest$flowCollect$3$1.emit(Merge.kt:33)
                                                                                                        at kotlinx.coroutines.flow.FlowKt__BuildersKt$asFlow$$inlined$unsafeFlow$2.collect(SafeCollector.common.kt:114)
                                                                                                        at kotlinx.coroutines.flow.internal.ChannelFlowTransformLatest$flowCollect$3.invokeSuspend(Merge.kt:27)
                                                                                                        at kotlinx.coroutines.flow.internal.ChannelFlowTransformLatest$flowCollect$3.invoke(Unknown Source:8)
                                                                                                        at kotlinx.coroutines.flow.internal.ChannelFlowTransformLatest$flowCollect$3.invoke(Unknown Source:4)
                                                                                                        at kotlinx.coroutines.intrinsics.UndispatchedKt.startUndispatchedOrReturn(Undispatched.kt:78)
                                                                                                        at kotlinx.coroutines.CoroutineScopeKt.coroutineScope(CoroutineScope.kt:264)
                                                                                                        at kotlinx.coroutines.flow.internal.ChannelFlowTransformLatest.flowCollect(Merge.kt:25)
                                                                                                        at kotlinx.coroutines.flow.internal.ChannelFlowOperator.collectTo$suspendImpl(ChannelFlow.kt:157)
                                                                                                        at kotlinx.coroutines.flow.internal.ChannelFlowOperator.collectTo(Unknown Source:0)
                                                                                                        at kotlinx.coroutines.flow.internal.ChannelFlow$collectToFun$1.invokeSuspend(ChannelFlow.kt:60)
                                                                                                        at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
                                                                                                        at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:108)
                                                                                                        at kotlinx.coroutines.internal.LimitedDispatcher$Worker.run(LimitedDispatcher.kt:115)
                                                                                                        at kotlinx.coroutines.scheduling.TaskImpl.run(Tasks.kt:103)
                                                                                                        at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:584)
                                                                                                        at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:793)
                                                                                                        at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:697)
                                                                                                        at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:684)
sdsantos commented 1 year ago

This was fixed by #339 because now it won't try to receive messages without at least on first-party endpoint, and it logs a message.