diff --git a/main.py b/main.py index 12b04719d..037a74b90 100644 --- a/main.py +++ b/main.py @@ -139,7 +139,16 @@ def execute_prestartup_script(): spec.loader.exec_module(module) return True except Exception as e: + import traceback logging.error(f"Failed to execute startup-script: {script_path} / {e}") + from nodes import NODE_STARTUP_ERRORS, get_module_name + node_module_name = get_module_name(os.path.dirname(script_path)) + NODE_STARTUP_ERRORS[node_module_name] = { + "module_path": os.path.dirname(script_path), + "error": str(e), + "traceback": traceback.format_exc(), + "phase": "prestartup", + } return False node_paths = folder_paths.get_folder_paths("custom_nodes") diff --git a/nodes.py b/nodes.py index 37ceac2fc..5430e4bc2 100644 --- a/nodes.py +++ b/nodes.py @@ -2181,6 +2181,9 @@ EXTENSION_WEB_DIRS = {} # Dictionary of successfully loaded module names and associated directories. LOADED_MODULE_DIRS = {} +# Dictionary of custom node startup errors, keyed by module name. +NODE_STARTUP_ERRORS: dict[str, dict] = {} + def get_module_name(module_path: str) -> str: """ @@ -2298,6 +2301,13 @@ async def load_custom_node(module_path: str, ignore=set(), module_parent="custom except Exception as e: logging.warning(traceback.format_exc()) logging.warning(f"Cannot import {module_path} module for custom nodes: {e}") + module_name = get_module_name(module_path) + NODE_STARTUP_ERRORS[module_name] = { + "module_path": module_path, + "error": str(e), + "traceback": traceback.format_exc(), + "phase": "import", + } return False async def init_external_custom_nodes(): diff --git a/server.py b/server.py index 27b14825e..1d0a2582b 100644 --- a/server.py +++ b/server.py @@ -758,6 +758,10 @@ class PromptServer(): out[node_class] = node_info(node_class) return web.json_response(out) + @routes.get("/custom_node_startup_errors") + async def get_custom_node_startup_errors(request): + return web.json_response(nodes.NODE_STARTUP_ERRORS) + @routes.get("/api/jobs") async def get_jobs(request): """List all jobs with filtering, sorting, and pagination.