{"record":{"id":"deecaf822d0708cf","repo":"wavetermdev/waveterm","slug":"failed-to-create-stderr-pipe-w-deecaf","errorCode":null,"errorMessage":"failed to create stderr pipe: %w","messagePattern":"failed to create stderr pipe: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/buildercontroller/buildercontroller.go","lineNumber":345,"sourceCode":"\tcmd := exec.Command(appBinPath)\n\tcmd.Env = append(os.Environ(), \"TSUNAMI_CLOSEONSTDIN=1\")\n\n\tif wavebase.IsDevMode() {\n\t\tcmd.Env = append(cmd.Env, \"TSUNAMI_CORS=\"+tsunamiutil.DevModeCorsOrigins)\n\t}\n\n\tfor key, value := range builderEnv {\n\t\tcmd.Env = append(cmd.Env, key+\"=\"+value)\n\t}\n\n\tstdoutPipe, err := cmd.StdoutPipe()\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to create stdout pipe: %w\", err)\n\t}\n\n\tstderrPipe, err := cmd.StderrPipe()\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to create stderr pipe: %w\", err)\n\t}\n\n\tstdinPipe, err := cmd.StdinPipe()\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to create stdin pipe: %w\", err)\n\t}\n\n\tportChan := make(chan int, 1)\n\tportFound := false\n\n\tbc.outputBuffer.SetLineCallback(func(line string) {\n\t\tif !portFound {\n\t\t\tif port := build.ParseTsunamiPort(line); port > 0 {\n\t\t\t\tportFound = true\n\t\t\t\tportChan <- port\n\t\t\t}\n\t\t}\n\t\tbc.publishOutputLine(line, false)","sourceCodeStart":327,"sourceCodeEnd":363,"githubUrl":"https://github.com/wavetermdev/waveterm/blob/a4447c1563b2df285ab89e76c82f91e1a1a49c1e/pkg/buildercontroller/buildercontroller.go#L327-L363","documentation":"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.","triggerScenarios":"cmd.StderrPipe() returns error — subprocess already started, or OS pipe/fd allocation failed.","commonSituations":"fd exhaustion under load (too many concurrent builds/connections); double-start of the builder command; resource leaks elsewhere in the server.","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"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"process, err := bc.runBuilderApp(ctx, ...)\nif err != nil {\n    var perr error\n    if errors.As(err, &perr) && strings.Contains(err.Error(), \"too many open files\") {\n        // raise ulimit or fix fd leaks, then retry\n    }\n    return err\n}","preventionTips":["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"],"tags":["go","os-exec","subprocess","pipe"],"backgroundTag":"os-exec-pipe-creation-failed","analyzedSha":"a4447c1563b2df285ab89e76c82f91e1a1a49c1e","analyzedAt":"2026-09-01T15:26:23.972Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}