anomalyco/sst · error

failed to create stderr pipe: %v

Error message

failed to create stderr pipe: %v

What it means

Raised in PythonRuntime.Run (pkg/runtime/python/python.go:206) when cmd.StderrPipe() fails after StdoutPipe succeeded. Same failure family as the stdout pipe: the command has already been started, or the OS cannot allocate another pipe (fd exhaustion). It wraps the underlying exec error so the dev server can surface why the Python worker could not be wired up.

Source

Thrown at pkg/runtime/python/python.go:206

		}

		// Join paths
		pythonPath := strings.Join(pythonPaths, string(os.PathListSeparator))
		env = append(env, "PYTHONPATH="+pythonPath)

		resourceEncPath := filepath.Join(input.Build.Out, "resource.enc")
		env = append(env, "SST_KEY_FILE="+resourceEncPath)
	}

	cmd.Env = env
	cmd.Dir = workingDir
	stdout, err := cmd.StdoutPipe()
	if err != nil {
		return nil, fmt.Errorf("failed to create stdout pipe: %v", err)
	}
	stderr, err := cmd.StderrPipe()
	if err != nil {
		return nil, fmt.Errorf("failed to create stderr pipe: %v", err)
	}

	if err := cmd.Start(); err != nil {
		return nil, fmt.Errorf("failed to start worker process: %v", err)
	}

	return &worker{
		stdout,
		stderr,
		cmd,
	}, nil

}

func (r *PythonRuntime) ShouldRebuild(functionID string, file string) bool {
	// Skip paths inside build artifacts, caches, or virtual envs to avoid feedback loops
	normalized := filepath.ToSlash(file)
	for _, dir := range []string{".sst", ".venv", "venv", "__pycache__", ".git", "node_modules", ".pytest_cache", ".mypy_cache", ".tox"} {

View on GitHub (pinned to a0bd20f762)

Solutions

  1. Inspect the wrapped error; if it says 'after Start', always create both pipes before cmd.Start()
  2. Raise ulimit -n and/or lower concurrency (SST_BUILD_CONCURRENCY_FUNCTION)
  3. Restart the dev session to release leaked fds from prior workers

Example fix

// before
stdout, _ := cmd.StdoutPipe()
cmd.Start()
stderr, err := cmd.StderrPipe() // error
// after
stdout, err := cmd.StdoutPipe()
if err != nil { return nil, err }
stderr, err := cmd.StderrPipe()
if err != nil { return nil, err }
cmd.Start()
Defensive patterns

Strategy: try-catch

Try / catch

w, err := rt.Run(ctx, input)
if err != nil {
    if strings.Contains(err.Error(), "failed to create stderr pipe") {
        // pipes must both be created before cmd.Start()
        return recreateWorkerWithPipesFirst(ctx, input)
    }
    return err
}

Prevention

When it happens

Trigger: OS fd exhaustion between the two pipe calls, or code path reusing a cmd that was already Start()ed (StderrPipe after Start returns an error).

Common situations: Many concurrent Python functions in sst dev exhausting file descriptors; sandboxed CI runners with tiny fd limits; modified runtime code that starts the command before wiring pipes.

Related errors


AI-assisted analysis of anomalyco/sst@a0bd20f762 (2026-08-30). Data as JSON: /api/errors/04b42710c2ee16e8. Report an issue: GitHub.