{"record":{"id":"2809bb5eaeab7c4e","repo":"wavetermdev/waveterm","slug":"failed-to-get-stdin-pipe-w","errorCode":null,"errorMessage":"failed to get stdin pipe: %w","messagePattern":"failed to get stdin pipe: %w","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/remote/connutil.go","lineNumber":132,"sourceCode":"\tinstallWords := map[string]string{\n\t\t\"installDir\":  filepath.ToSlash(filepath.Dir(wavebase.RemoteFullWshBinPath)),\n\t\t\"tempPath\":    wavebase.RemoteFullWshBinPath + \".temp\",\n\t\t\"installPath\": wavebase.RemoteFullWshBinPath,\n\t}\n\tvar installCmd bytes.Buffer\n\tif err := installTemplate.Execute(&installCmd, installWords); err != nil {\n\t\treturn fmt.Errorf(\"failed to prepare install command: %w\", err)\n\t}\n\tblocklogger.Infof(ctx, \"[conndebug] copying %q to remote server %q\\n\", wshLocalPath, wavebase.RemoteFullWshBinPath)\n\tgenCmd, err := genconn.MakeSSHCmdClient(client, genconn.CommandSpec{\n\t\tCmd: installCmd.String(),\n\t})\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to create remote command: %w\", err)\n\t}\n\tstdin, err := genCmd.StdinPipe()\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to get stdin pipe: %w\", err)\n\t}\n\tdefer stdin.Close()\n\tstderrBuf, err := genconn.MakeStderrSyncBuffer(genCmd)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to get stderr pipe: %w\", err)\n\t}\n\tif err := genCmd.Start(); err != nil {\n\t\treturn fmt.Errorf(\"failed to start remote command: %w\", err)\n\t}\n\tcopyDone := make(chan error, 1)\n\tgo func() {\n\t\tdefer close(copyDone)\n\t\tdefer stdin.Close()\n\t\tif _, err := io.Copy(stdin, input); err != nil && err != io.EOF {\n\t\t\tcopyDone <- fmt.Errorf(\"failed to copy data: %w\", err)\n\t\t} else {\n\t\t\tcopyDone <- nil\n\t\t}","sourceCodeStart":114,"sourceCodeEnd":150,"githubUrl":"https://github.com/wavetermdev/waveterm/blob/a4447c1563b2df285ab89e76c82f91e1a1a49c1e/pkg/remote/connutil.go#L114-L150","documentation":"After creating the remote install command, CpWshToRemote obtains a stdin pipe (used to stream the wsh binary to the remote shell) via genCmd.StdinPipe(). This error is wrapped when acquiring that pipe fails. The binary transfer cannot start without the pipe.","triggerScenarios":"genCmd.StdinPipe() returns an error — typically because the underlying SSH session/channel has already failed or closed after MakeSSHCmdClient succeeded, or the client implementation cannot allocate the pipe.","commonSituations":"Race where the remote command exits or the channel closes before StdinPipe is acquired; network drop between command creation and pipe setup; resource exhaustion in the SSH library (too many open channels).","solutions":["Retry the whole CpWshToRemote operation — transient channel races usually clear on a fresh exec session.","Verify network stability to the remote host; drops between MakeSSHCmdClient and StdinPipe indicate a flaky connection.","Check for SSH channel exhaustion (MaxSessions / many concurrent transfers) and serialize installs.","Inspect the wrapped error for the underlying SSH channel failure and address accordingly."],"exampleFix":null,"handlingStrategy":"retry","validationCode":"// verify the channel is usable before transfer\nif _, _, err := genconn.RunSimpleCommand(ctx, client, genconn.CommandSpec{Cmd: \"true\"}); err != nil {\n    return fmt.Errorf(\"ssh channel unavailable: %w\", err)\n}","typeGuard":null,"tryCatchPattern":"err := connutil.CpWshToRemote(ctx, client, os, arch)\nif err != nil && strings.Contains(err.Error(), \"failed to get stdin pipe\") {\n    // transient channel race — retry once on a fresh session\n    err = connutil.CpWshToRemote(ctx, reconnect(connName), os, arch)\n}","preventionTips":["Retry the whole copy operation on transient pipe errors; they usually indicate channel races.","Avoid many concurrent SSH channels to the same host (MaxSessions limits).","Ensure stable networking; drops between command creation and pipe setup point at flaky links.","Keep the genconn/SSH client library current to benefit from channel-handling fixes."],"tags":["go","ssh","io-pipe","wsh"],"backgroundTag":"ssh-pipe-failed","analyzedSha":"a4447c1563b2df285ab89e76c82f91e1a1a49c1e","analyzedAt":"2026-09-01T15:26:23.972Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}