{"record":{"id":"4ea46c61d229bf68","repo":"wavetermdev/waveterm","slug":"cannot-create-stdout-pipe-w","errorCode":null,"errorMessage":"cannot create stdout pipe: %w","messagePattern":"cannot create stdout pipe: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/wshrpc/wshremote/wshremote_job.go","lineNumber":163,"sourceCode":"\treadyPipeRead, readyPipeWrite, err := os.Pipe()\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"cannot create ready pipe: %w\", err)\n\t}\n\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}","sourceCodeStart":145,"sourceCodeEnd":181,"githubUrl":"https://github.com/wavetermdev/waveterm/blob/a4447c1563b2df285ab89e76c82f91e1a1a49c1e/pkg/wshrpc/wshremote/wshremote_job.go#L145-L181","documentation":"Returned when creating the stdout pipe for a spawned job fails, an OS resource-limit condition. The underlying error is wrapped with %w.","triggerScenarios":"Calling RemoteStartJobCommand when the parent process cannot allocate another pipe/file descriptor.","commonSituations":"Servers spawning many concurrent jobs without closing prior pipes; low fd ulimits in production containers.","solutions":["Fix fd leaks and ensure StdoutPipe handles are drained and closed per job","Raise the file descriptor limit for the server process","Cap concurrent job starts so pipe usage stays under the limit"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"var lim syscall.Rlimit\nsyscall.Getrlimit(syscall.RLIMIT_NOFILE, &lim)\nif lim.Cur-lim-used < 10 { /* approximate headroom check */ }","typeGuard":null,"tryCatchPattern":"rtn, err := server.RemoteStartJobCommand(ctx, data)\nif err != nil {\n    if strings.Contains(err.Error(), \"cannot create stdout pipe\") {\n        // pipe/fd allocation failed; inspect fd usage before retry\n    }\n    return err\n}","preventionTips":["Drain and close stdout pipes for every finished job","Raise RLIMIT_NOFILE in production configs","Alert on fd-count growth over time"],"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"}