/fork command crashes with 'undefined is not an object (evaluating T.match)'
Bug Description
Running the /fork command causes Claude Code to crash with a runtime error.
Steps to Reproduce
- Start a Claude Code session in a git repository
- Have a conversation with some context
- Run
/fork - Claude Code crashes
Error
ERROR undefined is not an object (evaluating 'T.match')
The crash occurs in the tool output rendering path. Based on the stack trace, a function that parses stderr for sandbox violation tags calls .match() on an undefined value — it appears stderr is undefined instead of an empty string when rendering the output of the fork operation.
Simplified stack trace (from minified source):
F_8 → d7T → Z$ → eH → WJ → Ev → GTT → Up → Np → oR
F_8 is the function that runs a regex match (/<sandbox_violations>...) against stderr, which is undefined at that point.
Environment
- Claude Code version: 2.1.38
- OS: macOS (Darwin 25.2.0)
- Platform: darwin arm64
- Shell: zsh
Expected Behavior
/fork should create a forked session without crashing.
Additional Context
The stderr parameter passed to the Bash output renderer appears to not be null-checked before .match() is called on it. A simple guard like stderr ?? "" before the regex match would prevent this crash.
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗