Skip to content

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

Description

@kernkraft235

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:

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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions