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
- Create StdoutPipe/StderrPipe/StdinPipe strictly before cmd.Start()
- Inspect wrapped error; for 'too many open files' fix leaks or raise the fd limit
- 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
- Create all three pipes in one place, before cmd.Start()
- Watch for EMFILE under concurrent builds; serialize or limit build concurrency
- Raise RLIMIT_NOFILE if builds run on busy hosts
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
- failed to create stdout pipe: %w
- failed to create stdin pipe: %w
- failed to start process: %w
- process died before emitting port
- timeout waiting for port
AI-assisted analysis of wavetermdev/waveterm@a4447c1563 (2026-09-01).
Data as JSON: /api/errors/deecaf822d0708cf.
Report an issue: GitHub.