Skip to content

Conversation

@craigvandotcom
Copy link

Problem

When errors occur during session execution (e.g., "Process exited unexpectedly"), the actual error details are lost in the logs:

[16:21:21.424] [remote]: launch error {}

The error object appears as {} because JSON.stringify() doesn't capture Error properties (message, stack, name) - they're not enumerable.

Solution

Added a serializeForLog() helper function that properly handles Error objects by explicitly extracting their non-enumerable properties.

Before

[16:21:21.424] [remote]: launch error {}

After

[16:21:21.424] [remote]: launch error {"name":"Error","message":"Connection refused","stack":"Error: Connection refused\n    at ..."}

Changes

  • Added serializeForLog() helper function in src/ui/logger.ts
  • Updated logToFile() to use the new helper
  • Updated sendToRemoteServer() to use the same helper for consistency
  • Added unit tests in src/ui/logger.test.ts

Testing

npx vitest run src/ui/logger.test.ts

All 7 tests pass:

  • String passthrough
  • Plain object serialization
  • Error serialization with name, message, stack
  • TypeError with correct name
  • Additional enumerable properties on errors
  • null/undefined handling
  • number/boolean handling

Impact

This fix will help users and maintainers debug "Process exited unexpectedly" errors by capturing the actual error details in logs at ~/.happy/logs/.


🤖 Generated with Claude Code

craigvandotcom and others added 4 commits January 7, 2026 19:44
Error objects logged with logger.debug() were appearing as {} because
JSON.stringify() doesn't capture non-enumerable Error properties (message,
stack, name).

Added serializeForLog() helper that explicitly extracts Error properties,
making debug logs actually useful for diagnosing issues like "Process
exited unexpectedly".

Before: [16:21:21.424] [remote]: launch error {}
After:  [16:21:21.424] [remote]: launch error {"name":"Error","message":"...","stack":"..."}

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Craig van Heerden <craig@example.com>
- docs/debugging/exit-code-1-investigation.md: Full technical investigation
- scripts/reproduce-crash.mjs: Minimal reproduction script

Key finding: Crash is Happy-internal race condition, not Claude Code bug.
Reproduction script stays alive 30+ seconds with identical flags.

Generated with [Claude Code](https://claude.ai/code)
via [Happy](https://happy.engineering)

Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Happy <yesreply@happy.engineering>
Root cause confirmed: Claude Code's "only prompt commands are supported
in streaming mode" error when using --resume with --input-format stream-json.

This is GitHub issue #16712 - Claude Code injects synthetic message before
reading stdin, breaking the message chain.

Added:
- Confirmed root cause section
- Potential workarounds
- References to relevant docs

Generated with [Claude Code](https://claude.ai/code)
via [Happy](https://happy.engineering)

Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Happy <yesreply@happy.engineering>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant