{"record":{"id":"fbbb5c74d85ddea8","repo":"wavetermdev/waveterm","slug":"cannot-create-stderr-pipe-w","errorCode":null,"errorMessage":"cannot create stderr pipe: %w","messagePattern":"cannot create stderr pipe: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/wshrpc/wshremote/wshremote_job.go","lineNumber":167,"sourceCode":"\tdefer readyPipeRead.Close()\n\tdefer readyPipeWrite.Close()\n\n\tcmd := exec.Command(wshPath, \"jobmanager\", \"--jobid\", data.JobId, \"--clientid\", data.ClientId)\n\tif data.PublicKeyBase64 != \"\" {\n\t\tcmd.Env = append(os.Environ(), \"WAVETERM_PUBLICKEY=\"+data.PublicKeyBase64)\n\t}\n\tcmd.ExtraFiles = []*os.File{readyPipeWrite}\n\tstdin, err := cmd.StdinPipe()\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"cannot create stdin pipe: %w\", err)\n\t}\n\tstdout, err := cmd.StdoutPipe()\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"cannot create stdout pipe: %w\", err)\n\t}\n\tstderr, err := cmd.StderrPipe()\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"cannot create stderr pipe: %w\", err)\n\t}\n\tlog.Printf(\"RemoteStartJobCommand: created pipes\\n\")\n\n\tif err := cmd.Start(); err != nil {\n\t\treturn nil, fmt.Errorf(\"cannot start job manager: %w\", err)\n\t}\n\treadyPipeWrite.Close()\n\tlog.Printf(\"RemoteStartJobCommand: job manager process started\\n\")\n\n\tjobAuthTokenLine := fmt.Sprintf(\"Wave-JobAccessToken:%s\\n\", data.JobAuthToken)\n\tif _, err := stdin.Write([]byte(jobAuthTokenLine)); err != nil {\n\t\tcmd.Process.Kill()\n\t\treturn nil, fmt.Errorf(\"cannot write job auth token: %w\", err)\n\t}\n\tstdin.Close()\n\tlog.Printf(\"RemoteStartJobCommand: wrote auth token to stdin\\n\")\n\n\tgo func() {","sourceCodeStart":149,"sourceCodeEnd":185,"githubUrl":"https://github.com/wavetermdev/waveterm/blob/a4447c1563b2df285ab89e76c82f91e1a1a49c1e/pkg/wshrpc/wshremote/wshremote_job.go#L149-L185","documentation":"Returned when creating the stderr pipe for a spawned job fails, an OS resource-limit condition. The underlying error is wrapped with %w.","triggerScenarios":"Calling RemoteStartJobCommand when fd allocation fails right before cmd.Start().","commonSituations":"fd exhaustion on hosts running many concurrent jobs or leaking descriptors over time.","solutions":["Audit and fix fd leaks (all pipes/streams per job must be closed)","Raise RLIMIT_NOFILE for the server process","Restart the process to reclaim descriptors"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"var lim syscall.Rlimit\nsyscall.Getrlimit(syscall.RLIMIT_NOFILE, &lim)\nif lim.Cur < 1024 {\n    return fmt.Errorf(\"fd limit too low\")\n}","typeGuard":null,"tryCatchPattern":"rtn, err := server.RemoteStartJobCommand(ctx, data)\nif err != nil {\n    if strings.Contains(err.Error(), \"cannot create stderr pipe\") {\n        // fd exhaustion; fix leaks or raise limits before retry\n    }\n    return err\n}","preventionTips":["Ensure all three std pipes are consumed/closed per job","Raise RLIMIT_NOFILE for the service","Cap concurrent jobs"],"tags":["os","file-descriptors","pipes","exec"],"backgroundTag":"too-many-open-files","analyzedSha":"a4447c1563b2df285ab89e76c82f91e1a1a49c1e","analyzedAt":"2026-09-01T15:26:23.972Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}