Skip to content

Commit 5d8d8b7

Browse files
committed
chore: update READMEs and robustness improvement
1 parent 37bd219 commit 5d8d8b7

File tree

16 files changed

+194
-46
lines changed

16 files changed

+194
-46
lines changed

README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -886,13 +886,16 @@ Acknowledge/ignore/resolve an issue.
886886
All logs are stored in:
887887

888888
```text
889-
ComfyUI/custom_nodes/ComfyUI-Doctor/logs/
889+
<ComfyUI user directory>/ComfyUI-Doctor/logs/
890890
```
891891

892892
Filename format: `comfyui_debug_YYYY-MM-DD_HH-MM-SS.log`
893893

894894
The system automatically retains the 10 most recent log files (configurable via `config.json`).
895895

896+
> Tip: You can check the resolved data directory via `GET /doctor/health``health.storage.data_dir`.
897+
> Legacy installs may still have logs under `ComfyUI/custom_nodes/ComfyUI-Doctor/logs/` (migrated when possible).
898+
896899
---
897900

898901
## Configuration

ROADMAP.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -678,10 +678,20 @@ graph TD
678678
- **Foundation for**: CI/CD integration, UI regression detection
679679
- [ ] **T13**: Desktop-style Failure Injection Tests (Flush/OSError + Corrupt JSON) - 🟡 Medium
680680
- **Goal**: Prevent Desktop-only regressions (log storms, broken history) without requiring a real ComfyUI Desktop runtime in CI.
681+
- **Status (2026-01-23)**: Guardrails exist (R18), but failure-injection coverage is still missing; schedule implementation later.
681682
- **Scope**:
682683
- Simulate stream flush failures (e.g. `OSError: [Errno 22] Invalid argument`) and assert rate-limit + aggregation behavior
683684
- Corrupt JSON recovery tests for history stores (`error_history.json`, diagnostics history)
684685
- Fixture corpus derived from `docs/reference/desktop/` (sanitized, no secrets)
686+
- **Missing coverage (to add)**:
687+
- Prestartup path/permission failures: log dir cannot be created / log file cannot be opened must not break startup (`prestartup_script.py`)
688+
- Desktop flush exception storms: ensure `FlushSafeProxy` + Desktop flush-ignore filter prevents recursive exception spam and history bloat (`logger.py`)
689+
- Store corruption self-heal: verify corrupt files are rotated aside and a clean store is recreated (`history_store.py`, `services/diagnostics/store.py`)
690+
- Migration invariants: legacy history is migrated and legacy file is renamed with `.migrated-<ts>` (R18 migration path)
691+
- **Implementation notes (when scheduled)**:
692+
- Prefer stdlib `unittest` (so tests don't depend on pytest being installed locally), but keep compatible with pytest discovery in CI.
693+
- Add a small fixture set under `tests/fixtures/desktop/` derived from `docs/reference/desktop/` (sanitized; no secrets).
694+
- Focus assertions on: bounded growth (aggregation window), no infinite recursion, and successful recovery after corruption.
685695
- [ ] **T9**: External Environment Test Coverage Expansion (Non-ComfyUI) - 🟡 Medium
686696
- **Goal**: Cover pipeline integration, SSE/REST contracts, and UI contracts without a live ComfyUI runtime
687697
- **Phases**:

config.py

Lines changed: 27 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
import os
77
import json
8+
import tempfile
89
from dataclasses import dataclass, asdict, field
910
from typing import Optional, List
1011

@@ -24,6 +25,9 @@ def _get_config_path_candidates() -> List[str]:
2425

2526
# Legacy location (extension root)
2627
candidates.append(os.path.join(os.path.dirname(__file__), "config.json"))
28+
29+
# OS temp fallback (last resort; avoids writing under Desktop resources)
30+
candidates.append(os.path.join(tempfile.gettempdir(), "ComfyUI-Doctor", "config.json"))
2731
return candidates
2832

2933

@@ -120,20 +124,32 @@ def load_config() -> DiagnosticsConfig:
120124

121125
def save_config(config: DiagnosticsConfig) -> bool:
122126
"""Save current configuration to config.json."""
123-
config_path = _get_primary_config_path()
124-
try:
125-
with open(config_path, "w", encoding="utf-8") as f:
126-
json.dump(config.to_dict(), f, indent=2, ensure_ascii=False)
127-
return True
128-
except Exception:
129-
# Fallback to legacy location if canonical dir is not writable.
127+
payload = json.dumps(config.to_dict(), indent=2, ensure_ascii=False)
128+
for config_path in _get_config_path_candidates():
130129
try:
131-
legacy_path = os.path.join(os.path.dirname(__file__), "config.json")
132-
with open(legacy_path, "w", encoding="utf-8") as f:
133-
json.dump(config.to_dict(), f, indent=2, ensure_ascii=False)
130+
dir_path = os.path.dirname(config_path)
131+
if dir_path:
132+
os.makedirs(dir_path, exist_ok=True)
133+
134+
tmp_path = f"{config_path}.tmp"
135+
with open(tmp_path, "w", encoding="utf-8") as f:
136+
f.write(payload)
137+
f.flush()
138+
try:
139+
os.fsync(f.fileno())
140+
except Exception:
141+
pass
142+
os.replace(tmp_path, config_path)
134143
return True
135144
except Exception:
136-
return False
145+
try:
146+
tmp_path = f"{config_path}.tmp"
147+
if os.path.exists(tmp_path):
148+
os.remove(tmp_path)
149+
except Exception:
150+
pass
151+
continue
152+
return False
137153

138154

139155
# Global config instance

docs/readme/README.de.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -823,7 +823,7 @@ Verfügbare Modelle vom konfigurierten LLM-Anbieter auflisten.
823823
Alle Logs werden gespeichert in:
824824

825825
```text
826-
ComfyUI/custom_nodes/ComfyUI-Doctor/logs/
826+
<ComfyUI user directory>/ComfyUI-Doctor/logs/
827827
```
828828

829829
Dateinamenformat: `comfyui_debug_YYYY-MM-DD_HH-MM-SS.log`

docs/readme/README.es.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -823,7 +823,7 @@ Listar modelos disponibles del proveedor LLM configurado.
823823
Todos los registros se almacenan en:
824824

825825
```text
826-
ComfyUI/custom_nodes/ComfyUI-Doctor/logs/
826+
<ComfyUI user directory>/ComfyUI-Doctor/logs/
827827
```
828828

829829
Formato de nombre de archivo: `comfyui_debug_YYYY-MM-DD_HH-MM-SS.log`

docs/readme/README.fr.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -823,7 +823,7 @@ Lister les modèles disponibles du fournisseur LLM configuré.
823823
Tous les journaux sont stockés dans :
824824

825825
```text
826-
ComfyUI/custom_nodes/ComfyUI-Doctor/logs/
826+
<ComfyUI user directory>/ComfyUI-Doctor/logs/
827827
```
828828

829829
Format du nom de fichier : `comfyui_debug_YYYY-MM-DD_HH-MM-SS.log`

docs/readme/README.it.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -823,7 +823,7 @@ Elenca i modelli disponibili dal provider LLM configurato.
823823
Tutti i log sono memorizzati in:
824824

825825
```text
826-
ComfyUI/custom_nodes/ComfyUI-Doctor/logs/
826+
<ComfyUI user directory>/ComfyUI-Doctor/logs/
827827
```
828828

829829
Formato nome file: `comfyui_debug_YYYY-MM-DD_HH-MM-SS.log`

docs/readme/README.ja.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -823,7 +823,7 @@ LLMプロバイダーへの接続をテストしてAPIキーの有効性を検
823823
すべてのログは以下に保存されます:
824824

825825
```text
826-
ComfyUI/custom_nodes/ComfyUI-Doctor/logs/
826+
<ComfyUI user directory>/ComfyUI-Doctor/logs/
827827
```
828828

829829
ファイル名形式: `comfyui_debug_YYYY-MM-DD_HH-MM-SS.log`

docs/readme/README.ko.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -824,7 +824,7 @@ LLM 공급자에 대한 연결을 테스트하여 API 키 유효성을 확인합
824824
모든 로그는 다음에 저장됩니다.
825825

826826
```text
827-
ComfyUI/custom_nodes/ComfyUI-Doctor/logs/
827+
<ComfyUI user directory>/ComfyUI-Doctor/logs/
828828
```
829829

830830
파일 이름 형식: `comfyui_debug_YYYY-MM-DD_HH-MM-SS.log`

docs/readme/README.zh-CN.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -824,13 +824,16 @@ curl http://localhost:8188/debugger/history
824824
所有日志存放于:
825825

826826
```text
827-
ComfyUI/custom_nodes/ComfyUI-Doctor/logs/
827+
<ComfyUI user directory>/ComfyUI-Doctor/logs/
828828
```
829829

830830
文件名格式为:`comfyui_debug_YYYY-MM-DD_HH-MM-SS.log`
831831

832832
系统会自动保留最新的 10 个日志文件(可透过 `config.json` 调整)。
833833

834+
> 提示:可用 `GET /doctor/health``health.storage.data_dir` 查看实际解析到的数据目录。
835+
> 旧版可能仍存在 `ComfyUI/custom_nodes/ComfyUI-Doctor/logs/`(可用时会自动迁移)。
836+
834837
---
835838

836839
## 配置参数

0 commit comments

Comments
 (0)