Skip to content

fix: claude code startup error#322

Closed
alpham8 wants to merge 2 commits intomksglu:nextfrom
alpham8:main
Closed

fix: claude code startup error#322
alpham8 wants to merge 2 commits intomksglu:nextfrom
alpham8:main

Conversation

@alpham8
Copy link
Copy Markdown

@alpham8 alpham8 commented Apr 22, 2026

What / Why / How

It fixes a claude code startup error. I'm not sure, if it affects other platforms as well.

Affected platforms

  • Claude Code
  • Cursor
  • VS Code Copilot (GitHub Copilot)
  • Gemini CLI
  • OpenCode
  • KiloCode
  • Codex CLI
  • OpenClaw (Pi Agent)
  • Kiro
  • Antigravity
  • Zed
  • All platforms

Test plan

Nothing - just a one-liner.

Checklist

  • Tests added/updated (TDD: red → green)
  • npm test passes
  • npm run typecheck passes
  • Docs updated if needed (README, platform-support.md)
  • No Windows path regressions (forward slashes only)
  • Targets next branch (unless hotfix)
Cross-platform notes

On claude code on Ubuntu (installed via linuxbrew), I saw this error at startup:

  ⎿  SessionStart:startup hook error                                                                                 ⎿  Failed with non-blocking status code: No stderr output
  ⎿  SessionStart:startup hook error                                                                                 ⎿  Failed with non-blocking status code: No stderr output

@mksglu mksglu changed the base branch from main to next April 25, 2026 15:49
mksglu added a commit that referenced this pull request Apr 25, 2026
…2 hook sites (#322)

All 22 hook files used raw JSON.parse(raw) which throws SyntaxError on
empty/whitespace stdin. On Ubuntu linuxbrew installs, Claude Code can
pipe empty stdin to SessionStart hooks, causing "Failed with non-blocking
status code" errors and silently disabling session continuity features.

Add parseStdin() helper to session-helpers.mjs that strips BOM, trims
whitespace, and returns {} for empty input. Replace all 22 JSON.parse(raw)
call sites across 6 adapters (Claude Code, Gemini CLI, VS Code Copilot,
Cursor, Codex CLI, Kiro) with parseStdin(raw).

Tests: 6 unit tests for parseStdin + 21 empty-stdin resilience tests
covering every hook file across all adapters. 70/70 pass.

Closes #322

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@mksglu
Copy link
Copy Markdown
Owner

mksglu commented Apr 25, 2026

Fixed comprehensively on next

Your bug report was spot-on — JSON.parse("") throws SyntaxError on empty stdin, silently disabling session continuity on affected installs.

Instead of patching just sessionstart.mjs, we fixed all 22 hook files across all 6 adapters with a central parseStdin() helper:

  • 1 new helper: parseStdin(raw) in session-helpers.mjs — strips BOM, trims, returns {} on empty input
  • 22 call sites fixed: Claude Code (5), Gemini CLI (4), VS Code Copilot (4), Cursor (4), Codex CLI (3), Kiro (2)
  • 27 new tests: 6 unit tests for parseStdin + 21 empty-stdin resilience tests covering every hook file

All 70 integration tests pass on macOS. CI covers Ubuntu + Windows.

Thank you @alpham8 for catching this! 🙏

Commit: 3e65ee5

@mksglu mksglu closed this Apr 25, 2026
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.

2 participants