Kotlin / kotlinx-rpc

Add asynchronous RPC services to your multiplatform applications.
https://kotlin.github.io/kotlinx-rpc/
Apache License 2.0
675 stars 16 forks source link

IllegalStateException in samples/ktor-web-app front-end #147

Closed marcdownie closed 1 week ago

marcdownie commented 1 month ago

Fresh checkout + minimum path to a running ktor-web-app:

git clone https://github.com/Kotlin/kotlinx-rpc.git
cd kotlinx-rpc/samples/ktor-web-app
./gradlew server:run &
./gradlew frontend:jsRun &

With that the http://localhost:300 that opens yields a stalled front-end (no messages appear sent from the server) and an IllegalStateException originating from (I believe) here: https://github.com/Kotlin/kotlinx-rpc/blob/d0ac56e00b32b7fe1fe6850a9d9423d75653d48c/samples/ktor-web-app/frontend/src/jsMain/kotlin/Welcome.kt#L31

Full dev-tools log here:

frontend.js:293 [webpack-dev-server] Server started: Hot Module Replacement enabled, Live Reloading enabled, Progress disabled, Overlay enabled.
frontend.js:456 [HMR] Waiting for update signal from WDS...
CoroutineExceptionHandlerImpl.kt:7 IllegalStateException: Flow invariant is violated:
        Flow was collected in [StandaloneCoroutine{Active}@1, Dispatchers.Main],
        but emission happened in [[object Object], UndispatchedCoroutine{Active}@2, Dispatchers.Main].
        Please refer to 'flow' documentation or use 'flowOn' instead
overrideMethod @ console.js:288
propagateExceptionFinalResort @ CoroutineExceptionHandlerImpl.kt:7
handleUncaughtCoroutineException @ CoroutineExceptionHandlerImpl.common.kt:48
handleCoroutineException @ CoroutineExceptionHandler.kt:28
protoOf.handleJobException_9fdet1_k$ @ Builders.common.kt:190
finalizeFinishingState @ JobSupport.kt:228
tryMakeCompletingSlowPath @ JobSupport.kt:917
tryMakeCompleting @ JobSupport.kt:874
protoOf.makeCompletingOnce_b13xy2_k$ @ JobSupport.kt:839
protoOf.resumeWith_dtxwbr_k$ @ AbstractCoroutine.kt:97
protoOf.resumeWith_b9cu3x_k$ @ Continuation.kt:54
protoOf.resumeWith_dtxwbr_k$ @ kotlin-kotlin-stdlib.js:5761
protoOf.afterResume_ugh2hm_k$ @ CoroutineContext.kt:56
protoOf.resumeWith_dtxwbr_k$ @ AbstractCoroutine.kt:99
protoOf.resumeWith_b9cu3x_k$ @ Continuation.kt:54
protoOf.resumeWith_dtxwbr_k$ @ kotlin-kotlin-stdlib.js:5761
protoOf.run_mvkpxh_k$ @ Continuation.kt:45
protoOf.process_myqcf5_k$ @ JSDispatcher.kt:127
eval @ JSDispatcher.kt:55
Promise.then (async)
protoOf.schedule_o777if_k$ @ JSDispatcher.kt:55
protoOf.enqueue_uiib2n_k$ @ JSDispatcher.kt:118
protoOf.dispatch_qa3n0o_k$ @ JSDispatcher.kt:56
dispatch @ DispatchedTask.kt:157
dispatchResume @ CancellableContinuationImpl.kt:466
protoOf.completeResume_fabtk_k$ @ CancellableContinuationImpl.kt:582
tryResume0 @ BufferedChannel.kt:2927
tryResumeReceiver @ BufferedChannel.kt:669
updateCellSend @ BufferedChannel.kt:481
protoOf.trySend_62dpg8_k$ @ BufferedChannel.kt:304
eval @ JsWebSocketSession.kt:67
Show 1 more frame
Show less
ConsoleOutputAppender.kt:9 WARN: [RPCConnector[Client][34d20442]] No registered service of MyService service type was able to process message at the moment. Waiting for new services.
overrideMethod @ console.js:288
protoOf.logFormattedMessage_32jwnf_k$ @ ConsoleOutputAppender.kt:9
protoOf.log_1olo2n_k$ @ Standard.kt:13
protoOf.at_qj7uuo_k$ @ Standard.kt:27
at$default @ kotlin-logging.js:195
warn @ KLogger.kt:36
protoOf.warn_n6vn8g_k$ @ CommonLoggerImpl.kt:56
protoOf.doResume_5yljmg_k$ @ RPCConnector.kt:161
processServiceMessage @ RPCConnector.kt:153
protoOf.doResume_5yljmg_k$ @ RPCConnector.kt:128
processMessage_0 @ RPCConnector.kt:126
processMessage @ RPCConnector.kt:123
protoOf.doResume_5yljmg_k$ @ RPCConnector.kt:99
protoOf.resumeWith_b9cu3x_k$ @ Standard.kt:55
protoOf.resumeWith_dtxwbr_k$ @ kotlin-kotlin-stdlib.js:5761
protoOf.run_mvkpxh_k$ @ Continuation.kt:45
protoOf.process_myqcf5_k$ @ JSDispatcher.kt:127
eval @ JSDispatcher.kt:55
Promise.then (async)
protoOf.schedule_o777if_k$ @ JSDispatcher.kt:55
protoOf.enqueue_uiib2n_k$ @ JSDispatcher.kt:118
protoOf.dispatch_qa3n0o_k$ @ JSDispatcher.kt:56
dispatch @ DispatchedTask.kt:157
dispatchResume @ CancellableContinuationImpl.kt:466
protoOf.completeResume_fabtk_k$ @ CancellableContinuationImpl.kt:582
tryResume0 @ BufferedChannel.kt:2927
tryResumeReceiver @ BufferedChannel.kt:669
updateCellSend @ BufferedChannel.kt:481
protoOf.trySend_62dpg8_k$ @ BufferedChannel.kt:304
eval @ JsWebSocketSession.kt:67
Show 1 more frame
Show less
Mr3zee commented 1 month ago

Hi! Thanks for pointing it out! We'll fix the example

realityexpander commented 1 month ago

AH, ok, i thought I was going crazy... I hope for a fix soon!