Skip to content

[Bug] prepare-commit-msg hook blocks every commit on LLM latency with no overall timeout #271

Description

@404-Page-Found

Summary

The prepare-commit-msg hook runs buildProfile() + generateSuggestions() synchronously inside the git commit path. The hook has no overall deadline of its own — a slow or stalled provider delays every commit for up to the per-request timeout (30s, src/providers/request.ts:1), and a provider outage adds seconds of latency to each commit before degrading to a warning. To an end user, git commit appears to hang.

Location

  • src/git/hook.ts:196-208runPrepareCommitMsgHook: LLM calls block commit
  • src/providers/request.ts:1DEFAULT_PROVIDER_REQUEST_TIMEOUT_MS = 30_000

Code snippet

// src/git/hook.ts (inside prepare-commit-msg, blocks `git commit`)
const profile = await deps.buildProfile(config.historySize);
const { suggestions } = await deps.generateSuggestions(config, diffResult.diff, profile);
const selected = suggestions[0];
...
await deps.writeMessageFile(args.messageFile, nextContent);

Suggested fix

Give the hook a tight overall deadline (e.g. abort suggestion generation after a few seconds and leave the commit message unchanged), so provider slowness can never block a commit for the full 30s. Consider also skipping the LLM call entirely when the provider appears unreachable (fast health check) or when --no-verify semantics apply.

Impact

  • Every commit's latency is coupled to LLM provider health; a hung provider stalls all commits for up to 30s each.
  • Users who install the hook and later hit a provider outage perceive git itself as broken.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinggood first issueGood for newcomers

    Type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions