wavetermdev/waveterm · error

failed to create stderr pipe: %w

Error message

failed to create stderr pipe: %w

What it means

Same family as the stdout-pipe error: runBuilderApp calls cmd.StderrPipe() on the os/exec Cmd for the builder subprocess, and Go failed to allocate the stderr pipe. Typically caused by calling it after Start() or by OS-level fd exhaustion.

Source

Thrown at pkg/buildercontroller/buildercontroller.go:345

	cmd := exec.Command(appBinPath)
	cmd.Env = append(os.Environ(), "TSUNAMI_CLOSEONSTDIN=1")

	if wavebase.IsDevMode() {
		cmd.Env = append(cmd.Env, "TSUNAMI_CORS="+tsunamiutil.DevModeCorsOrigins)
	}

	for key, value := range builderEnv {
		cmd.Env = append(cmd.Env, key+"="+value)
	}

	stdoutPipe, err := cmd.StdoutPipe()
	if err != nil {
		return nil, fmt.Errorf("failed to create stdout pipe: %w", err)
	}

	stderrPipe, err := cmd.StderrPipe()
	if err != nil {
		return nil, fmt.Errorf("failed to create stderr pipe: %w", err)
	}

	stdinPipe, err := cmd.StdinPipe()
	if err != nil {
		return nil, fmt.Errorf("failed to create stdin pipe: %w", err)
	}

	portChan := make(chan int, 1)
	portFound := false

	bc.outputBuffer.SetLineCallback(func(line string) {
		if !portFound {
			if port := build.ParseTsunamiPort(line); port > 0 {
				portFound = true
				portChan <- port
			}
		}
		bc.publishOutputLine(line, false)

View on GitHub (pinned to a4447c1563)

Solutions

  1. Create StdoutPipe/StderrPipe/StdinPipe strictly before cmd.Start()
  2. Inspect wrapped error; for 'too many open files' fix leaks or raise the fd limit
  3. Verify no concurrent calls to runBuilderApp share one exec.Cmd instance
Defensive patterns

Strategy: try-catch

Try / catch

process, err := bc.runBuilderApp(ctx, ...)
if err != nil {
    var perr error
    if errors.As(err, &perr) && strings.Contains(err.Error(), "too many open files") {
        // raise ulimit or fix fd leaks, then retry
    }
    return err
}

Prevention

When it happens

Trigger: cmd.StderrPipe() returns error — subprocess already started, or OS pipe/fd allocation failed.

Common situations: fd exhaustion under load (too many concurrent builds/connections); double-start of the builder command; resource leaks elsewhere in the server.

Related errors


AI-assisted analysis of wavetermdev/waveterm@a4447c1563 (2026-09-01). Data as JSON: /api/errors/deecaf822d0708cf. Report an issue: GitHub.