mirror of
https://github.com/Monkopedia/rouse-context.git
synced 2026-11-22 05:16:11 +00:00
1.0.13 crashed every incoming session with NetworkOnMainThreadException. #781 replaced a java.net.Socket connected under withContext(Dispatchers.IO) with a Ktor socket, whose connect calls SocketChannel.connect synchronously on the calling thread -- and handleStream is called from lifecycleScope, i.e. the Android main thread. serveStream now runs under an injected ioDispatcher (default Dispatchers.IO): cert/Keystore loading, TLS accept, MCP session create/stop, the loopback connect, the copy loops and the socket close. closeStream hops to it too, outside serveStream's hop so a caller cancelled before it still sends CLOSE (#796). Suspending on IO holds no thread while a session idles, so #781's behaviour is unchanged. SessionHandlerCallerThreadTest calls handleStream from a single-thread stand-in for the main thread and records the thread of each seam, observing the connect via a recording SelectorProvider. Claude-Session: https://claude.ai/code/session_01YYSPuh9bZEJkrzvnEpY1QK Co-authored-by: monkopedia-coder <monkopedia-coder@users.noreply.github.com> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> |
||
|---|---|---|
| .. | ||
| src | ||
| build.gradle.kts | ||