mirror of
https://github.com/oven-sh/bun
synced 2026-02-18 23:01:58 +00:00
### What does this PR do? When Error.captureStackTrace(e, fn) is called with a function that isn't in the call stack, all frames are filtered out and e.stack should return just the error name and message (e.g. "Error: test"), matching Node.js behavior. Previously Bun returned undefined because: 1. The empty frame vector replaced the original stack frames via setStackFrames(), but the lazy stack accessor was only installed when hasMaterializedErrorInfo() was true (i.e. stack was previously accessed). When it wasn't, JSC's internal materialization saw the empty/null frames and produced no stack property at all. 2. The custom lazy getter returned undefined when stackTrace was nullptr, instead of computing the error name+message string with zero frames. Fix: always force materialization before replacing frames, always install the custom lazy accessor, and handle nullptr stackTrace in the getter by computing the error string with an empty frame list. ### How did you verify your code works? --------- Co-authored-by: Claude Bot <claude-bot@bun.sh> Co-authored-by: Claude <noreply@anthropic.com> Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>