fix: sanitize CLAUDECODE env var in daemon-spawned sessions#736
Open
pemagic wants to merge 1 commit intoslopus:mainfrom
Open
fix: sanitize CLAUDECODE env var in daemon-spawned sessions#736pemagic wants to merge 1 commit intoslopus:mainfrom
pemagic wants to merge 1 commit intoslopus:mainfrom
Conversation
When the daemon is started from within a Claude Code terminal, it inherits
the CLAUDECODE=1 environment variable. This causes all daemon-spawned
child sessions to fail because Claude CLI detects it and refuses to start,
thinking it's a nested session.
Remove CLAUDECODE from the environment in all spawn paths:
- scripts/claude_remote_launcher.cjs
- scripts/claude_local_launcher.cjs
- src/claude/sdk/query.ts (SDK spawn)
- src/claude/claudeLocal.ts (local mode spawn)
- src/daemon/run.ts (daemon child spawn)
Also fix error logging in claudeRemoteLauncher.ts and metadataExtractor.ts
where Error objects were logged as {} due to JSON.stringify not serializing
non-enumerable Error properties.
Fixes slopus#735
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
CLAUDECODE=1env var before spawning Claude CLI in all spawn paths, preventing "Process exited unexpectedly" when daemon is started from a Claude Code terminal{}(non-enumerable properties), making debugging impossibleRoot Cause
When the Happy daemon is started from within a Claude Code terminal, it inherits
CLAUDECODE=1. Claude CLI detects this and refuses to start, thinking it's a nested session. The daemon didn't sanitize this variable before spawning child processes.The error was invisible in logs because
JSON.stringify(new Error("msg"))returns{}.Changes
CLAUDECODE removal (5 locations):
scripts/claude_remote_launcher.cjsscripts/claude_local_launcher.cjssrc/claude/sdk/query.tssrc/claude/claudeLocal.tssrc/daemon/run.tsError logging fix (2 locations):
src/claude/claudeRemoteLauncher.ts— extracte.message+e.stacksrc/claude/sdk/metadataExtractor.ts— extracterror.messageTest plan
Fixes #735
🤖 Generated with Claude Code