-
Notifications
You must be signed in to change notification settings - Fork 181
Description
I started with a working code that only operates pass-by-value serializable data classes. I converted one of the methods to return a StateFlow<T>
instead of T
:
// before (works)
override fun myZiplineServiceMethod(): MyType = _myValue
private var _myValue: MyType = someInitialValue
// now (doesn't work)
override fun myZiplineServiceMethod(): StateFlow<MyType> = _myValue
private val _myValue: MutableStateFlow<MyType> = MutableStateFlow(someInitialValue)
On the client-side the only difference is that I now call .value
to get the value.
The zipline part compiles fine, but I get a crash at runtime, when I call .value
:
Exception in thread "main" app.cash.zipline.QuickJsException: stack overflow
at app.cash.zipline.JniCallChannel.call(Native Method)
at app.cash.zipline.JniCallChannel.call(JniCallChannel.kt:25)
at app.cash.zipline.Zipline$endpoint$1.call(Zipline.kt:65)
at app.cash.zipline.internal.bridge.OutboundCallHandler.callInternal$zipline(OutboundCallHandler.kt:116)
at app.cash.zipline.internal.bridge.OutboundCallHandler.call(OutboundCallHandler.kt:75)
at app.cash.zipline.internal.bridge.StateFlowZiplineService$Companion$Adapter$GeneratedOutboundService.getValue(flows.kt:34)
at app.cash.zipline.internal.bridge.StateFlowSerializer$toStateFlow$1.getValue(flows.kt:145)
[here my client code calls .value on a StateFlow instance it received from zipline]
I used to get this error before when there were circular dependencies in my pass-by-value data classes which makes sense (also I would appreciate a more meaningful error message). But what happens here I have no idea.
I also tried using regular Flows before discovering from a random issue that StateFlows are supported too (please please work on the docs!) and with minimal changes got a QuickJs cannot read property "set_value_v1vabv_k$" of undefined
and a SIGSEGV (!) on two separate occasions with even less info to work with. This is out of scope of this issue though.