Comfy-Org / Comfy-Org/ComfyUI_frontend

Circular deps: auth-telemetry-config initialization cluster

Open
#11,096 0 comments 0 reactions 0 assignees View on GitHub
area:auth audit:refactor code-audit developer experience
Dominant language
TypeScript
Stars
2k
Forks
699
Avg merge
1d 7h
Merged PRs (30d)
490

Description

## Problem

`dpdm` detected a circular dependency cluster involving auth stores, telemetry providers, and API config:

```
remoteConfig.ts → types.ts → telemetry/types.ts → customerEventsService.ts → comfyApi.ts → (back to remoteConfig)
firebaseAuthStore → telemetry/index → MixpanelTelemetryProvider → useCurrentUser → apiKeyAuthStore → (back to firebaseAuthStore)
```

### Root cause

- `remoteConfig/types.ts` imports `TelemetryEventName` from `telemetry/types.ts`
- `customerEventsService.ts` imports from `config/comfyApi.ts` which creates the cycle back
- `MixpanelTelemetryProvider` imports `useCurrentUser` which imports both auth stores, while auth stores depend on telemetry

### Impact

- Fragile initialization ordering — store/service may be undefined at import time
- Harder to test in isolation
- Potential runtime issues with circular imports

### Suggested fix

- Extract shared types (e.g. `TelemetryEventName`) to a leaf-level types file that doesn't import from services
- Break the auth → telemetry → auth cycle by having telemetry accept a user-info getter via dependency injection rather than importing auth stores directly

### Files involved

- `src/platform/remoteConfig/remoteConfig.ts`
- `src/platform/remoteConfig/types.ts`
- `src/platform/telemetry/types.ts`
- `src/platform/telemetry/index.ts`
- `src/platform/telemetry/providers/cloud/MixpanelTelemetryProvider.ts`
- `src/services/customerEventsService.ts`
- `src/config/comfyApi.ts`
- `src/stores/firebaseAuthStore.ts`
- `src/composables/auth/useCurrentUser.ts`
- `src/stores/apiKeyAuthStore.ts`

Parent: #11022

┆Issue is synchronized with this [Notion page](https://www.notion.so/Issue-11096-Circular-deps-auth-telemetry-config-initialization-cluster-33e6d73d3650819b9eaecb6000d906d8) by [Unito](https://www.unito.io)

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.