Skip to content

fix(cli): resolve dev-mode spawn crash and improve early exit handling#244

Open
falconlux wants to merge 1 commit intotiann:mainfrom
falconlux:fix/dev-spawn-cwd-resolution
Open

fix(cli): resolve dev-mode spawn crash and improve early exit handling#244
falconlux wants to merge 1 commit intotiann:mainfrom
falconlux:fix/dev-spawn-cwd-resolution

Conversation

@falconlux
Copy link

Summary

  • Fix @/ path alias resolution failure when runner spawns child processes in dev mode (Bun resolves tsconfig relative to cwd, which was the user's project dir instead of cli/)
  • Fix webhook timeout not resolving immediately on early child process exit (was waiting full 15s)

Changes

  • spawnHappyCLI.ts: In dev mode, override cwd to cli/ for tsconfig resolution, pass real directory via HAPI_SPAWN_CWD env; add getSpawnedWorkingDirectory() helper
  • run.ts: Add pidToSpawnReject map so onChildExited resolves spawn awaiter immediately on crash
  • All agent runners (claude, codex, cursor, gemini, opencode, agentSession): Use getSpawnedWorkingDirectory() instead of process.cwd()

Test plan

  • Typecheck passes across all packages
  • Runner spawns agent sessions successfully (verified via runner logs)
  • Resume session from web PWA - session should start without crash

🤖 Generated with Claude Code
via Happy

Two fixes for session spawn in development mode:

1. Fix @/ path alias resolution when runner spawns child processes:
   In dev mode, Bun resolves tsconfig path aliases relative to cwd.
   When spawning agent sessions, cwd was set to the user's project
   directory (not cli/), causing @/ imports to fail. Now spawnHappyCLI
   overrides cwd to cli/ and passes the real directory via HAPI_SPAWN_CWD
   env variable, which all agent runners read via getSpawnedWorkingDirectory().

2. Fix webhook timeout not resolving on early child exit:
   When a spawned agent process crashed immediately, the spawn awaiter
   waited the full 15s timeout before returning an error. Now
   onChildExited resolves the awaiter immediately, reducing failed
   resume attempts from ~30s to instant.

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