{"record":{"id":"63468154c81dec2c","repo":"kovidgoyal/kitty","slug":"timed-out-while-waiting-to-read-cmd-response","errorCode":null,"errorMessage":"Timed out while waiting to read cmd response","messagePattern":"Timed out while waiting to read cmd response","errorType":"exception","errorClass":"TimeoutError","httpStatus":null,"severity":"error","filePath":"kitty/remote_control.py","lineNumber":363,"sourceCode":"                out.write(data)\n            else:\n                for chunk in data:\n                    if isinstance(chunk, str):\n                        chunk = chunk.encode('utf-8')\n                    out.write(chunk)\n                    out.flush()\n        self.socket.shutdown(socket.SHUT_WR)\n\n    def simple_recv(self, timeout: float) -> bytes:\n        dcs = re.compile(rb'\\x1bP@kitty-cmd([^\\x1b]+)\\x1b\\\\')\n        self.socket.settimeout(timeout)\n        st = monotonic()\n        with self.socket.makefile('rb') as src:\n            data = src.read()\n        m = dcs.search(data)\n        if m is None:\n            if monotonic() - st > timeout:\n                raise TimeoutError('Timed out while waiting to read cmd response')\n            raise SocketClosed('Remote control connection was closed by kitty without any response being received')\n        return bytes(m.group(1))\n\n\nclass RCIO(TTYIO):\n    def simple_recv(self, timeout: float) -> bytes:\n        ans: list[bytes] = []\n        read_command_response(self.tty_fd, timeout, ans)\n        return b''.join(ans)\n\n\ndef do_io(to: str | None, original_cmd: dict[str, Any], no_response: bool, response_timeout: float, encrypter: 'CommandEncrypter') -> dict[str, Any]:\n    payload = original_cmd.get('payload')\n    if not isinstance(payload, GeneratorType):\n        send_data: bytes | Iterator[bytes] = encode_send(encrypter(original_cmd))\n    else:\n\n        def send_generator() -> Iterator[bytes]:","sourceCodeStart":345,"sourceCodeEnd":381,"githubUrl":"https://github.com/kovidgoyal/kitty/blob/6d5d0c440603ad9bdf6dcd599f73f6dde21acb44/kitty/remote_control.py#L345-L381","documentation":"The remote-control client reads the response from kitty's socket; if no DCS-framed response arrives within the timeout, TimeoutError is raised. Typically kitty never answered (busy, hung, or the command was swallowed).","triggerScenarios":"@kitten remote-control command over a slow/hung transport (SSH, or kitty busy rendering) where monotonic() - start exceeds the timeout before any data with a DCS match.","commonSituations":"Remote control over SSH to a loaded machine, kitty frozen, or kitty version mismatch where responses aren't framed as expected.","solutions":["Retry the command (transient load is common)","Increase the timeout if the API exposes one","Verify kitty is responsive and the remote-control socket path is correct","Check for kitty version mismatches between client and server"],"exampleFix":null,"handlingStrategy":"retry","validationCode":"import subprocess\nr = subprocess.run(['pgrep','-x','kitty']); assert r.returncode==0, 'kitty not running'","typeGuard":null,"tryCatchPattern":"for attempt in range(3):\n    try: run_cmd()\n    except TimeoutError: sleep(1)\n    else: break","preventionTips":["Verify kitty is responsive before issuing RC commands","Use a generous timeout over slow SSH links"],"tags":["kitty","remote-control","timeout"],"backgroundTag":"response-timeout","analyzedSha":"6d5d0c440603ad9bdf6dcd599f73f6dde21acb44","analyzedAt":"2026-08-27T14:20:20.142Z","schemaVersion":2},"datasetVersion":"2026-08-27T19:17:21.184Z"}