coder / coder/coder-jetbrains-toolbox
Toolbox window disappears: uncaught `IllegalStateException: RpcClient was cancelled` from environments view after a network change
- Dominant language
- Kotlin
- Stars
- 23
- Forks
- 7
- Avg merge
- 3d 12h
- Merged PRs (30d)
- 10
Description
## Summary
When the Coder plugin's environments view queries `SettingsService.getEnvironmentInfo` over RPC and the underlying RPC channel has been cancelled (which happens on a network drop / network change), the call throws `java.lang.IllegalStateException: RpcClient was cancelled`.
This exception is not caught by the plugin and propagates up to Toolbox's `ComposeWindowsService` as an "Unhandled exception in a window 'Toolbox'".
When this happens, every time you open the toolbox and the plugin again it crashes. Only a toolbox force quit and restart fixes it.
## Environment
- **Coder Toolbox plugin:** v0.9.0 (latest release)
- **JetBrains Toolbox:** 3.5.0.84344
- **OS:** Windows 11 Pro (build 26200)
- **Coder deployment:** self-hosted
## Steps to reproduce
1. Connect to one or more Coder workspaces from the Toolbox Coder plugin (so RPC/SSH channels are live).
2. Trigger a network change/drop. The RPC keepalive then times out / the socket closes, logged as `SocketException: Socket closed` and `KeepaliveTimeoutException: Connection timed out`.
3. Open / return to the Coder plugin's environments view while a previously-connected workspace's RPC channel is in the cancelled state.
4. Now the Toolbox window can no longer be accessed
## Primary stack trace
```
ComposeWindowsService Unhandled exception in a window 'Toolbox':
java.lang.IllegalStateException: RpcClient was cancelled
at kotlinx.rpc.krpc.client.KrpcClient$callServerStreaming$1.invokeSuspend(KrpcClient.kt:265)
at kotlinx.coroutines.flow.SafeFlow.collectSafely(Builders.kt:57)
at kotlinx.coroutines.flow.AbstractFlow.collect(Flow.kt:226)
at kotlinx.coroutines.flow.FlowKt__ReduceKt.first(Reduce.kt:196)
at kotlinx.rpc.krpc.client.KrpcClient.call(KrpcClient.kt:258)
at com.jetbrains.toolbox.agentNetworkApi.settings.SettingsService$$rpcServiceStub.getEnvironmentInfo(SettingsService.kt)
at com.jetbrains.toolbox.viewmodel.DevEnvironmentProviderViewModelImpl$combinedEnvironmentState$$inlined$flatMapLatest$1.invokeSuspend(Merge.kt:190)
... (kotlinx.coroutines flow/combine machinery)
```
## Secondary, related render-thread exception (less frequent)
```
ComposeWindowsService Unhandled exception in a window 'Toolbox':
java.awt.IllegalComponentStateException: component must be showing on the screen to determine its location
at java.desktop/java.awt.Component.getLocationOnScreen_NoTreeLock(...)
at androidx.compose.ui.platform.PlatformWindowContext.convertLocalToScreenPosition-R5De75A(PlatformWindowContext.desktop.kt:132)
at androidx.compose.ui.scene.ComposeSceneMediator$DesktopPlatformContext.convertLocalToScreenPosition-MK-Hz9U(ComposeSceneMediator.desktop.kt:795)
at androidx.compose.ui.node.RootNodeOwner.updatePositionCacheAndDispatch(RootNodeOwner.skiko.kt:229)
```
## Connection
It seems that in general, reconnecting after network change seems to not work sometimes.
The coder workspaces are connected through the coder proxy, no direct connections
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.