# Bun Read stderr from a child process

> Read stderr from a child process

- Skill: `jarle/bun-read-stderr-from-a-child-process` (Agent Skill)
- Install (CLI): `npx skillmds@latest add jarle/bun-read-stderr-from-a-child-process`
- Raw SKILL.md: https://api.skillmd.com/api/skills/jarle/bun-read-stderr-from-a-child-process/raw
- Safety review: pending (external: skill-scanner PASS, skillspector PASS)
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: Coding & Dev Tools
- Author: jarle (https://skillmd.com/u/jarle)
- Updated: 2026-09-21
- Page: https://skillmd.com/skills/jarle/bun-read-stderr-from-a-child-process

---


# Read stderr from a child process

When using [`Bun.spawn()`](/runtime/child-process), the child process inherits the `stderr` of the spawning process. If instead you'd prefer to read and handle `stderr`, set the `stderr` option to `"pipe"`.

```ts  theme={"theme":{"light":"github-light","dark":"dracula"}}
const proc = Bun.spawn(["echo", "hello"], {
  stderr: "pipe",
});

proc.stderr; // => ReadableStream
```

***

To read `stderr` until the child process exits, use .text()

```ts  theme={"theme":{"light":"github-light","dark":"dracula"}}
const proc = Bun.spawn(["echo", "hello"], {
  stderr: "pipe",
});

const errors: string = await proc.stderr.text();
if (errors) {
  // handle errors
}
```

***

See [Docs > API > Child processes](/runtime/child-process) for complete documentation.

