Hi. We use ktor-client-websockets-js in our app an...
# ktor
a
Hi. We use ktor-client-websockets-js in our app and we regularly get reports about IllegalStateException in our error reporting system. This exception happens inside the library and we cannot handle it. JS stacktrace
Copy code
IllegalStateException Already resumed, but proposed with update CompletedExceptionally[WebSocketException: {"target":{},"type":"error","isTrusted":true}]
/static/js/bundle.js in alreadyResumedError at line 106495:11
/static/js/bundle.js in protoOf.resumeImpl_fj866n_k$ at line 106806:9
/static/js/bundle.js in protoOf.resumeImpl$default_lcn2bl_k$ at line 106814:12
/static/js/bundle.js in protoOf.resumeWith_dtxwbr_k$ at line 106730:17
/static/js/bundle.js in WebSocket.<anonymous> at line 142816:16
And deobfuscated version
Copy code
Uncaught IllegalStateException {"message": "Already resumed, but proposed with update CompletedExceptionally[WebSocketException:{\"target\":{},\"type\":\"error\",\"isTrusted\":true}]","name": "IllegalStateException"}
alreadyResumedError		@	Preconditions.kt:143
(anonymous)				@	CancellableContinuationImpl.kt:521
(anonymous)				@	CancellableContinuationImpl.kt:496
(anonymous)				@	CancellableContinuationImpl.kt:359
(anonymous)				@	Continuation.kt:54
From the information we’ve gathered so far, the exception below seems to be the trigger, but it's also beyond our control, we cannot catch it:
Copy code
WebSocket connection to 'ws://***/api/v1/ws' failed: Data frame received after close
createWebSocket        	@	JsClientEngine.kt:72
(anonymous function)   	@	JsClientEngine.kt:91
executeWebSocketRequest	@	JsClientEngine.kt:84
(anonymous)				@	JsClientEngine.kt:37
(anonymous)				@	JsClientEngine.kt:32
(anonymous)				@	HttpClientEngine.kt:99
(anonymous)				@	HttpClientEngine.kt:94
l						@	HttpClientEngine.kt:94
(anonymous)				@	IntrinsicsJs.kt:197
(anonymous)				@	Standard.kt:50
(anonymous)				@	CoroutineImpl.kt:25
(anonymous)				@	Continuation.kt:119
(anonymous)				@	JSDispatcher.kt:127
(anonymous)				@	JSDispatcher.kt:55
It's when the server send the text frame after close. I'm not sure if the server in fact send messages in such an order, or client just closes the connection and after that receives the text frame. I tried to write a demo for this to reproduce but without success.