Skip to content

fix(cli): suppress OSError EIO on interrupt shutdown (salvages #13720, closes #13710)#15834

Merged
teknium1 merged 2 commits into
mainfrom
hermes/hermes-865d6fcb
Apr 26, 2026
Merged

fix(cli): suppress OSError EIO on interrupt shutdown (salvages #13720, closes #13710)#15834
teknium1 merged 2 commits into
mainfrom
hermes/hermes-865d6fcb

Conversation

@teknium1

Copy link
Copy Markdown
Contributor

Salvages @voidborne-d's PR #13720 onto current main.

Summary

Interrupts during long-running tasks crashed with OSError: [Errno 5] Input/output error when prompt_toolkit's vt100 renderer flushed a broken stdout during emergency shutdown. _suppress_closed_loop_errors only caught RuntimeError + KeyError, and the outer except (KeyError, OSError) only matched "Bad file descriptor" — EIO fell through and killed the process.

Changes

  • cli.py: EIO guard added to both the asyncio exception handler and the outer stdin-unusable except block. Silently suppressed (correct — this only fires during interrupt teardown).
  • tests/hermes_cli/test_suppress_eio_on_interrupt.py: new, 9 tests covering EIO suppression + non-suppression of unrelated errors.
  • scripts/release.py: AUTHOR_MAP entry for voidborne-d's personal commit email.

Validation

Before After
Targeted tests n/a 9/9 pass
py_compile cli.py clean clean

Closes #13710. Credits #13720 (@voidborne-d). #13792 is a narrower attempt at the same issue and will be closed in favor of this.

voidborne-d and others added 2 commits April 25, 2026 18:23
When the user interrupts a long-running task, prompt_toolkit tries to
flush stdout during emergency shutdown.  If stdout is in a broken state
(redirected to /dev/null, pipe closed, terminal gone), the flush raises
`OSError: [Errno 5] Input/output error` which propagates unhandled and
crashes the CLI.

Two defense layers:

1. `_suppress_closed_loop_errors`: add `OSError` with `errno.EIO` to
   the asyncio exception handler, matching the existing pattern for
   `RuntimeError("Event loop is closed")` and `KeyError("is not
   registered")`.

2. Outer `except (KeyError, OSError)` block: add `errno.EIO` check
   before the existing string-match guards, silently suppressing the
   error instead of printing a misleading stdin-related message.

Fixes #13710.
@teknium1 teknium1 merged commit edce752 into main Apr 26, 2026
9 of 11 checks passed
@teknium1 teknium1 deleted the hermes/hermes-865d6fcb branch April 26, 2026 01:25
@alt-glitch alt-glitch added type/bug Something isn't working P2 Medium — degraded but workaround exists comp/cli CLI entry point, hermes_cli/, setup wizard labels Apr 26, 2026
@alt-glitch

Copy link
Copy Markdown
Collaborator

Supersedes #13720 and #13792 — same EIO suppression fix, salvaged onto current main with broader test coverage. Closes #13710.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/cli CLI entry point, hermes_cli/, setup wizard P2 Medium — degraded but workaround exists type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

CLI crashes with OSError: [Errno 5] Input/output error on interrupt (signal handling)

2 participants