ory/hydra · error

newWorker: failed to create stderr pipe

Error message

newWorker: failed to create stderr pipe

What it means

`newWorker` calls `cmd.StderrPipe()` to capture the child's error stream; failure here aborts worker creation with this wrapped error. As with the other pipe creations, the root cause is practically always inability to allocate new file descriptors in the parent process.

Source

Thrown at oryx/jsonnetsecure/jsonnet_pool.go:155

	}

	in := make(chan []byte, 1)
	go func(c <-chan []byte) {
		for input := range c {
			if _, err := stdin.Write(append(input, 0)); err != nil {
				stdin.Close()
				return
			}
		}
	}(in)

	stdout, err := cmd.StdoutPipe()
	if err != nil {
		return worker{}, errors.Wrap(err, "newWorker: failed to create stdout pipe")
	}
	stderr, err := cmd.StderrPipe()
	if err != nil {
		return worker{}, errors.Wrap(err, "newWorker: failed to create stderr pipe")
	}

	if err := cmd.Start(); err != nil {
		return worker{}, errors.Wrap(err, "newWorker: failed to start process")
	}

	span.SetAttributes(semconv.ProcessPID(cmd.Process.Pid))

	scan := func(c chan<- string, r io.Reader, maxTokenSize int) {
		defer close(c)
		scanner := bufio.NewScanner(r)
		scanner.Buffer(make([]byte, 0, 64*KiB), maxTokenSize)

		scanner.Split(splitNull)
		for scanner.Scan() {
			c <- scanner.Text()
		}
		if err := scanner.Err(); err != nil {

View on GitHub (pinned to 4174065ffb)

Solutions

  1. Raise the process fd limit (`ulimit -n`, systemd LimitNOFILE, K8s securityContext)
  2. Count fds via `/proc/<pid>/fd` and fix leaks — make sure `Pool.Close()` is called and workers are destroyed
  3. Reduce concurrent pool sizes / reuse a single pool instead of creating per-request pools
  4. If the system is genuinely out of resources, restart the service and add fd monitoring/alerting
Defensive patterns

Strategy: validation

Validate before calling

var lim syscall.Rlimit
syscall.Getrlimit(syscall.RLIMIT_NOFILE, &lim)
if fdCount()+2 >= int(lim.Cur) {
    return errors.New("cannot allocate stderr pipe: fd limit reached")
}

Prevention

When it happens

Trigger: Puddle pool constructor invoking `newWorker`: `cmd.StderrPipe()` returns an error — fd exhaustion (EMFILE/ENFILE) or, rarely, the OS refusing pipe allocation (pipe-full / ENOMEM on exotic systems).

Common situations: Container with a tiny default nofile limit; long-lived service accumulating leaked fds until every new pipe fails; many pools or per-request VMs each spawning workers.

Related errors


AI-assisted analysis of ory/hydra@4174065ffb (2026-09-03). Data as JSON: /api/errors/d8a33ba17090cacc. Report an issue: GitHub.