Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Dec 14, 2025

Claude Code hangs on startup after plugin installation when hooks encounter errors (worker not ready, first-time setup, connection failures). Root cause: uncaught promise rejections in hook entry points leave processes hanging instead of exiting cleanly.

Changes

Hook Entry Points - Added error handlers to all lifecycle hooks:

  • context-hook.ts - .catch() handler for TTY path, try-catch for stdin path
  • new-hook.ts, save-hook.ts, summary-hook.ts - try-catch wrappers in stdin handlers
  • cleanup-hook.ts - .catch() for TTY path, try-catch for stdin path

All error paths now log to stderr and exit with code 1.

Before/After

Before:

stdin.on('end', async () => {
  const parsed = input.trim() ? JSON.parse(input) : undefined;
  const text = await contextHook(parsed);  // Uncaught rejection → hang
  console.log(JSON.stringify({hookSpecificOutput: {...}}));
  process.exit(0);
});

After:

stdin.on('end', async () => {
  try {
    const parsed = input.trim() ? JSON.parse(input) : undefined;
    const text = await contextHook(parsed);
    console.log(JSON.stringify({hookSpecificOutput: {...}}));
    process.exit(0);
  } catch (error: any) {
    console.error(error.message || String(error));
    process.exit(1);  // Clean exit instead of hang
  }
});

Hooks now fail gracefully with error messages instead of causing Claude Code to freeze during startup.

Original prompt

This section details on the original issue you should resolve

<issue_title>Can't open claude code when I install this plugin</issue_title>
<issue_description>Describe the bug
A clear and concise description of what the bug is.

To Reproduce
Steps to reproduce the behavior:

  1. Install plugin
  2. Exit claude code
  3. Open a new claude code
  4. Stuck

Expected behavior
A clear and concise description of what you expected to happen.
I can use claude code nomally.
Screenshots
If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

  • OS: [e.g. iOS] Macos
  • Browser [e.g. chrome, safari] terminal
  • Version [e.g. 22] 26

Smartphone (please complete the following information):

  • Device: [e.g. iPhone6] Macbook air m4
  • OS: [e.g. iOS8.1]
  • Browser [e.g. stock browser, safari]
  • Version [e.g. 22]

Additional context
Add any other context about the problem here.
</issue_description>

Comments on the Issue (you are @copilot in this section)


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI changed the title [WIP] Fix issue opening claude code after plugin installation Fix: Add error handling to hook entry points to prevent startup hang Dec 14, 2025
Copilot AI requested a review from thedotmack December 14, 2025 19:09
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.

Can't open claude code when I install this plugin

2 participants