From cd693a3b8a2ba1711b5675788201bd8e1fc15151 Mon Sep 17 00:00:00 2001 From: Andrea Pozzetti Date: Fri, 13 Feb 2026 00:42:40 +0100 Subject: [PATCH] readded tracer --- prestartup_script.py | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/prestartup_script.py b/prestartup_script.py index 016160c3..6c06ab55 100644 --- a/prestartup_script.py +++ b/prestartup_script.py @@ -9,6 +9,38 @@ from comfy_3d_viewers import copy_viewer setup_env() +# --- Diagnostic hooks (active when COMFY_ENV_DEBUG=1) --- +if os.environ.get("COMFY_ENV_DEBUG", "").lower() in ("1", "true", "yes"): + import atexit + + def _exit_hook(): + print("[geompack] atexit handler called — clean Python shutdown", + file=sys.stderr, flush=True) + atexit.register(_exit_hook) + + _orig_excepthook = sys.excepthook + def _crash_excepthook(exc_type, exc_value, exc_tb): + print(f"[geompack] UNHANDLED: {exc_type.__name__}: {exc_value}", + file=sys.stderr, flush=True) + _orig_excepthook(exc_type, exc_value, exc_tb) + sys.excepthook = _crash_excepthook + + class _ImportTracer: + """Log first-time imports of key modules to identify crash location.""" + _PREFIXES = ('comfy', 'execution', 'server', 'protocol', 'nodes', + 'torch', 'comfyui_version', 'hook_breaker', 'comfy_aimdo', + 'app', 'cuda_malloc') + + def find_spec(self, fullname, path=None, target=None): + if fullname not in sys.modules: + parts = fullname.split('.') + if parts[0] in self._PREFIXES and len(parts) <= 2: + print(f"[import-trace] {fullname}", + file=sys.stderr, flush=True) + return None + + sys.meta_path.insert(0, _ImportTracer()) + SCRIPT_DIR = Path(__file__).resolve().parent COMFYUI_DIR = SCRIPT_DIR.parent.parent