kovidgoyal/kitty · error
Failed to send message to kitty with I/O error: %w
Error message
Failed to send message to kitty with I/O error: %w
What it means
Writing the JSON message body to the backend pipe returned an I/O error — typically EPIPE because the kitty subprocess died, or the pipe was closed concurrently. Raised inside the send goroutine.
Source
Thrown at kittens/choose_fonts/backend.go:78
k.wait_for_exit <- k.cmd.Wait()
}()
return
}
var kitty_font_backend kitty_font_backend_type
func (k *kitty_font_backend_type) send(v any) error {
if k.to == nil {
return fmt.Errorf("Trying to send data when to pipe is nil")
}
data, err := json.Marshal(v)
if err != nil {
return fmt.Errorf("Could not encode message to kitty with error: %w", err)
}
c := make(chan error)
go func() {
if _, err = k.to.Write(data); err != nil {
c <- fmt.Errorf("Failed to send message to kitty with I/O error: %w", err)
return
}
if _, err = k.to.Write([]byte{'\n'}); err != nil {
c <- fmt.Errorf("Failed to send message to kitty with I/O error: %w", err)
return
}
c <- nil
}()
select {
case err := <-c:
return err
case <-time.After(k.timeout):
return fmt.Errorf("Timed out waiting to write to kitty font backend after %v", k.timeout)
case err := <-k.wait_for_exit:
k.exited = true
if err == nil {
err = fmt.Errorf("kitty font backend exited with no error while waiting for a response from it")
} else {View on GitHub (pinned to 6d5d0c4406)
Solutions
- Check k.stderr and process exit state to find why the backend died
- Restart the backend (start()) and retry the query once
- Verify the kitty executable and its kittens package are intact/consistent versions
Example fix
// before
err := backend.send(msg)
// after
if err := backend.send(msg); err != nil {
if strings.Contains(err.Error(), "I/O error") {
backend.restart(); err = backend.send(msg)
}
} Defensive patterns
Strategy: retry
Validate before calling
if kitty_font_backend.cmd.ProcessState != nil && kitty_font_backend.cmd.ProcessState.Exited() { /* restart backend before sending */ } Try / catch
On write error, capture stderr, restart the backend via start(), and resend the message once; abort on second failure.
Prevention
- Keep kitty and kittens versions consistent
- Watch the backend process and log its stderr from the start
When it happens
Trigger: k.to.Write(data) fails after the '+runpy' kitty process exited (crash, kill, or normal shutdown racing a query).
Common situations: Backend python process crashed (import error in kittens.choose_fonts.backend); kitty was closed while a font query was in flight; pipe buffer closed early.
Related errors
- Failed to find the kitty executable, this kitten requires th
- Trying to send data when to pipe is nil
- Could not encode message to kitty with error: %w
- The font specification %s is invalid as %s does not contain
- Terminal does not support querying the: %s
AI-assisted analysis of kovidgoyal/kitty@6d5d0c4406 (2026-08-27).
Data as JSON: /api/errors/5c2d3a8dc07b89c3.
Report an issue: GitHub.