{"record":{"id":"f5a062c1d1f726bf","repo":"pulumi/pulumi","slug":"running-pager-w","errorCode":null,"errorMessage":"running pager: %w","messagePattern":"running pager: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/cmd/esc/cli/pager/noop.go","lineNumber":39,"sourceCode":")\n\nfunc runNoopPager(stdout io.Writer, f func(context.Context, io.Writer) error) error {\n\tctx, cancel := context.WithCancel(context.Background())\n\tdefer cancel()\n\n\tr, stdin := io.Pipe()\n\tdefer r.Close()\n\n\tdone := make(chan error)\n\tgo func() {\n\t\tdone <- func() error {\n\t\t\tdefer stdin.Close()\n\t\t\treturn f(ctx, stdin)\n\t\t}()\n\t}()\n\n\tif _, err := io.Copy(stdout, r); err != nil {\n\t\treturn fmt.Errorf(\"running pager: %w\", err)\n\t}\n\tcancel()\n\n\treturn <-done\n}\n","sourceCodeStart":21,"sourceCodeEnd":45,"githubUrl":"https://github.com/pulumi/pulumi/blob/793f7b2e160db4321fb7fb6b0607461e01cb251e/pkg/cmd/esc/cli/pager/noop.go#L21-L45","documentation":"The no-op pager's runNoopPager copies the command output through an io.Pipe to stdout. If the copy fails mid-stream (e.g. the writing goroutine's function errored and closed the pipe writer, or stdout became unwritable), the error is wrapped as \"running pager: %w\". Despite the message, this is in the fallback (non-pager) path.","triggerScenarios":"Output is written through the pipe while the producer function f(ctx, stdin) fails and closes the writer prematurely, or io.Copy fails writing to stdout (broken pipe, e.g. `esc ... | head` closing downstream, or a full/closed stdout).","commonSituations":"Piping ESC CLI output into `head` or a command that exits early, causing EPIPE on stdout; downstream consumer crashes while the CLI is streaming JSON output.","solutions":["Check the wrapped cause: an EPIPE usually means the downstream consumer (head, grep -q) closed early — handle SIGPIPE or avoid closing early","Retry the command writing directly to a file instead of a pipe","Capture output to a file (`> out.json`) to rule out pipe issues","If the producer function failed, inspect its error for the root cause"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// prefer capturing to a file to avoid pipe failures\nesc env get my-env --output json > out.json","typeGuard":null,"tryCatchPattern":"out, err := exec.Command(\"esc\", \"env\", \"get\", \"my-env\").Output()\nif err != nil {\n\tvar ee *exec.ExitError\n\tif errors.As(err, &ee) && isBrokenPipe(ee) {\n\t\t// downstream consumer (head, grep -q) closed the pipe: treat as benign\n\t\treturn nil\n\t}\n\treturn err\n}","preventionTips":["Avoid piping output into commands that exit early (head, grep -q) or handle SIGPIPE","Capture output to a file when chaining commands in scripts","Check that stdout is writable in the execution environment"],"tags":["cli","pager","io"],"backgroundTag":"broken-pipe","analyzedSha":"793f7b2e160db4321fb7fb6b0607461e01cb251e","analyzedAt":"2026-08-31T09:36:43.099Z","schemaVersion":2},"datasetVersion":"2026-09-01T08:17:40.651Z"}