relaycorp / awala-poweb-jvm

JVM implementation of the Awala PoWeb binding
MIT License
0 stars 1 forks source link

`IllegalStateException: Flow exception transparency is violated` #323

Closed gnarea closed 7 months ago

gnarea commented 8 months ago

The Awala gateway just crashed because of the exception above.

Unfortunately, the logs prior to the crash were lost by the time I plugged the phone (Pixel 8) to the computer, but I captured this which suggests a bug in this library:

2024-01-10 17:15:26.024  9441-9441  AndroidRuntime          pid-9441                             E  FATAL EXCEPTION: main
                                                                                                    Process: tech.relaycorp.gateway, PID: 9441
                                                                                                    java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
                                                                                                        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:562)
                                                                                                        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:971)
                                                                                                    Caused by: java.lang.reflect.InvocationTargetException
                                                                                                        at java.lang.reflect.Method.invoke(Native Method)
                                                                                                        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:552)
                                                                                                        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:971) 
                                                                                                    Caused by: android.os.strictmode.LeakedClosableViolation: A resource was acquired at attached stack trace but never released. See java.io.Closeable for information on avoiding resource leaks.
                                                                                                        at android.os.StrictMode$AndroidCloseGuardReporter.report(StrictMode.java:1994)
                                                                                                        at dalvik.system.CloseGuard.warnIfOpen(CloseGuard.java:336)
                                                                                                        at java.io.FileInputStream.finalize(FileInputStream.java:508)
                                                                                                        at java.lang.Daemons$FinalizerDaemon.doFinalize(Daemons.java:339)
                                                                                                        at java.lang.Daemons$FinalizerDaemon.processReference(Daemons.java:324)
                                                                                                        at java.lang.Daemons$FinalizerDaemon.runInternal(Daemons.java:300)
                                                                                                        at java.lang.Daemons$Daemon.run(Daemons.java:145)
                                                                                                        at java.lang.Thread.run(Thread.java:1012)
                                                                                                    Caused by: java.lang.Throwable: Explicit termination method 'close' not called
                                                                                                        at dalvik.system.CloseGuard.openWithCallSite(CloseGuard.java:288)
                                                                                                        at dalvik.system.CloseGuard.open(CloseGuard.java:257)
                                                                                                        at java.io.FileInputStream.<init>(FileInputStream.java:176)
                                                                                                        at tech.relaycorp.gateway.data.disk.DiskMessageOperations$readMessage$2.invoke(DiskMessageOperations.kt:39)
                                                                                                        at tech.relaycorp.gateway.data.disk.DiskMessageOperations$readMessage$2.invoke(DiskMessageOperations.kt:39)
                                                                                                        at tech.relaycorp.gateway.domain.endpoint.CollectParcels.getInputStream(CollectParcels.kt:70)
                                                                                                        at tech.relaycorp.gateway.domain.endpoint.CollectParcels.access$getInputStream(CollectParcels.kt:24)
                                                                                                        at tech.relaycorp.gateway.domain.endpoint.CollectParcels$getInputStream$1.invokeSuspend(Unknown Source:19)
                                                                                                        at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
                                                                                                        at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:108)
                                                                                                        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)
2024-01-10 17:17:40.555 19717-19776 AndroidRuntime          pid-19717                            E  FATAL EXCEPTION: DefaultDispatcher-worker-4
                                                                                                    Process: tech.relaycorp.gateway, PID: 19717
                                                                                                    java.lang.IllegalStateException: Flow exception transparency is violated:
                                                                                                        Previous 'emit' call has thrown exception java.io.EOFException, but then emission attempt of value 'tech.relaycorp.relaynet.bindings.pdc.ParcelCollection@cc25341' has been detected.
                                                                                                        Emissions from 'catch' blocks are prohibited in order to avoid unspecified behaviour, 'Flow.catch' operator can be used instead.
                                                                                                        For a more detailed explanation, please refer to Flow documentation.
                                                                                                        at kotlinx.coroutines.flow.internal.SafeCollector.exceptionTransparencyViolated(SafeCollector.kt:140)
                                                                                                        at kotlinx.coroutines.flow.internal.SafeCollector.checkContext(SafeCollector.kt:104)
                                                                                                        at kotlinx.coroutines.flow.internal.SafeCollector.emit(SafeCollector.kt:83)
                                                                                                        at kotlinx.coroutines.flow.internal.SafeCollector.emit(SafeCollector.kt:66)
                                                                                                        at tech.relaycorp.poweb.PoWebClient.collectAndAckParcels(PoWebClient.kt:253)
                                                                                                        at tech.relaycorp.poweb.PoWebClient.access$collectAndAckParcels(PoWebClient.kt:74)
                                                                                                        at tech.relaycorp.poweb.PoWebClient$collectAndAckParcels$1.invokeSuspend(Unknown Source:19)
                                                                                                        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)
                                                                                                        Suppressed: kotlinx.coroutines.internal.DiagnosticCoroutineContextException: [StandaloneCoroutine{Cancelling}@6ec1640, Dispatchers.IO]
2024-01-10 17:19:19.499 20319-20349 AndroidRuntime          pid-20319                            E  FATAL EXCEPTION: DefaultDispatcher-worker-4
                                                                                                    Process: tech.relaycorp.gateway, PID: 20319
                                                                                                    java.lang.IllegalStateException: Flow exception transparency is violated:
                                                                                                        Previous 'emit' call has thrown exception java.io.EOFException, but then emission attempt of value 'tech.relaycorp.relaynet.bindings.pdc.ParcelCollection@670b7d4' has been detected.
                                                                                                        Emissions from 'catch' blocks are prohibited in order to avoid unspecified behaviour, 'Flow.catch' operator can be used instead.
                                                                                                        For a more detailed explanation, please refer to Flow documentation.
                                                                                                        at kotlinx.coroutines.flow.internal.SafeCollector.exceptionTransparencyViolated(SafeCollector.kt:140)
                                                                                                        at kotlinx.coroutines.flow.internal.SafeCollector.checkContext(SafeCollector.kt:104)
                                                                                                        at kotlinx.coroutines.flow.internal.SafeCollector.emit(SafeCollector.kt:83)
                                                                                                        at kotlinx.coroutines.flow.internal.SafeCollector.emit(SafeCollector.kt:66)
                                                                                                        at tech.relaycorp.poweb.PoWebClient.collectAndAckParcels(PoWebClient.kt:253)
                                                                                                        at tech.relaycorp.poweb.PoWebClient.access$collectAndAckParcels(PoWebClient.kt:74)
                                                                                                        at tech.relaycorp.poweb.PoWebClient$collectAndAckParcels$1.invokeSuspend(Unknown Source:19)
                                                                                                        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)
                                                                                                        Suppressed: kotlinx.coroutines.internal.DiagnosticCoroutineContextException: [StandaloneCoroutine{Cancelling}@55eb61f, Dispatchers.IO]
sdsantos commented 8 months ago

@gnarea That resembles the issue fixed with https://github.com/relaycorp/awala-poweb-jvm/pull/307 and it even points to the old line count. Just checked and we are still using a Gateway without the fix. Here's a PR to take care of that: https://github.com/relaycorp/relaynet-gateway-android/pull/727