Commit Graph

2 Commits

Author SHA1 Message Date
maweibin
586107002a fix(runtime): throw typed ExitError instead of generic Error for simulated exit (#97796) (#97803)
createNonExitingRuntime.exit() threw a generic Error, making it
impossible for upstream try-catch to distinguish a simulated process
exit from a real runtime crash. Added an ExitError class (internal-only,
not exported from SDK) that callers can check via instanceof.

ExitError is kept internal to avoid expanding the public plugin SDK
API surface without maintainer approval. Tests import directly from
./runtime.js.

Fixes #97796.

Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-06 16:07:32 +00:00
dwc1997
0635a8c1a8 test(runtime): add unit tests for terminal runtime helpers (#96736)
Add unit tests for createNonExitingRuntime and writeRuntimeJson
functions in src/runtime.ts to verify runtime behavior.

Tests cover:
- createNonExitingRuntime returns runtime with exit function
- exit function throws error with code
- writeRuntimeJson writes JSON using writeJson when available
- writeRuntimeJson writes JSON using log when writeJson not available
- uses custom space parameter
- handles zero space parameter
2026-06-28 18:35:56 -07:00