Comfy-Org / Comfy-Org/comfy-cli

PostHog client is initialized unconditionally during fish shell completion, adding ~10 seconds to every completion

Open
#506 1 comment 0 reactions 0 assignees View on GitHub
bug
Dominant language
Python
Stars
968
Forks
151
Avg merge
1d 9h
Merged PRs (30d)
77

Description

On my system, each completion invocation takes approximately 10.6 seconds because importing the CLI unconditionally initializes a PostHog background worker and completions invoke the comfy command twice. Suppressing PostHog reduces completion to roughly 0.8 seconds because the CLI is executed twice.

IDK if the fact that I have strict DNS blocking is what’s causing posthog to take the full 5s each time, but it seems possible

Therefore, there appear to be two related performance problems:

1. Shell completion invokes the entire CLI twice per completion attempt.
2. CLI startup eagerly initializes telemetry and other command infrastructure that completion does not need.

Analytics are disabled in my configuration, which makes the unconditional PostHog initialization additionally surprising.

## Environment

- comfy-cli: 1.12.0
- Shell: Fish
- OS: Linux
- Analytics disabled in the Comfy configuration
- DNS-level tracking-domain blocking is enabled

## Reproduction

Compare an ordinary invocation of tabbing for a completion in fish shell then:

```fish
set -gx POSTHOG_API_KEY
```

It’s still kinda slow but it’s way more usable when you don’t post your hog each completion (~10s reduced to ~1s)

Contributor guide

Open the contributing guide

Research direction

Start by tracing the fish completion entry point and the repeated comfy command invocation, then follow CLI startup to where PostHog is initialized. Compare completion timing with analytics enabled and suppressed; done means completion no longer performs unnecessary telemetry initialization and the reported delay is reduced.

Written by the indexing model from the issue text.

Assessment

Tech stack
fish, python
Domain
cli, performance
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.