hashicorp/nomad · warning
failed to resize tty: %v
Error message
failed to resize tty: %v
What it means
handleStdin processes stdin frames from the client; when a frame carries a TtySize it resizes the pty via setTTYSize. On failure it pushes this wrapped error onto errCh, which runTTY/runNoTTY surface to the caller. The process keeps running but the terminal resize did not apply.
Source
Thrown at drivers/shared/executor/exec_utils.go:199
errCh <- err
return
}
if m.Stdin != nil {
if len(m.Stdin.Data) != 0 {
_, err := stdin.Write(m.Stdin.Data)
if err != nil {
errCh <- err
return
}
}
if m.Stdin.Close {
stdin.Close()
}
} else if m.TtySize != nil {
err := setTTYSize(stdin, m.TtySize.Height, m.TtySize.Width)
if err != nil {
errCh <- fmt.Errorf("failed to resize tty: %v", err)
return
}
}
}
}
func handleStdout(logger hclog.Logger, reader io.Reader, wg *sync.WaitGroup, send func(*drivers.ExecTaskStreamingResponseMsg) error, errCh chan<- error) {
defer wg.Done()
buf := make([]byte, 4096)
for {
n, err := reader.Read(buf)
// always send output first if we read something
if n > 0 {
if err := send(&drivers.ExecTaskStreamingResponseMsg{
Stdout: &dproto.ExecTaskStreamingIOOperation{
Data: buf[:n],
},View on GitHub (pinned to 482b49bf1a)
Solutions
- Verify the task was started with tty=true if interactive resize is expected
- Ignore/retry: the resize error is often transient after process exit; restart the exec session
- Check /dev/pts availability in the execution environment
- Update the client so resize frames are only sent for TTY sessions
Example fix
// before // nomad alloc exec -task web /bin/sh # task started without tty // after // ensure driver task config has tty = true, or omit TtySize frames for non-tty tasks
Defensive patterns
Strategy: retry
Validate before calling
func canResize(taskTTY bool) error {
if !taskTTY { return errors.New("resize frame requested for non-tty task") }
if _, err := os.Stat("/dev/pts"); err != nil { return err }
return nil
} Try / catch
if err := attachExecSession(); err != nil {
if strings.Contains(err.Error(), "failed to resize tty") {
// transient: pty may have closed; retry once, then drop resize handling
time.Sleep(100 * time.Millisecond)
return retryAttach()
}
return err
} Prevention
- Only send TtySize frames for sessions started with tty=true
- Handle resize errors as non-fatal in terminal clients
- Ensure devpts is mounted in exec environments
- Close sessions promptly after process exit
When it happens
Trigger: Client sends a stdin message with TtySize set (terminal window resize in exec/alloc UI or `nomad alloc exec` with tty) and setTTYSize fails — most often because stdin is not actually a pty (TIOCSWINSZ ioctl fails ENOTTY) or the pty was already closed.
Common situations: Attaching to a non-TTY task that receives resize frames, pty closed after process exit while a resize frame is in flight, running inside environments without pty support (CI, restricted containers), Windows terminal clients negotiating sizes on non-pty sessions.
Related errors
- failed to start command: %v
- failed to get pty: %v
- attempted to resize a non-tty session
- not a terminal
- stdin is not supported
AI-assisted analysis of hashicorp/nomad@482b49bf1a (2026-09-04).
Data as JSON: /api/errors/09932c096e56ce35.
Report an issue: GitHub.