Skip to content

Commit d30c1ad

Browse files
docs(app): explain why errors are handled poorly
1 parent b1f819a commit d30c1ad

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

invokeai/app/services/session_processor/session_processor_default.py

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,11 +60,23 @@ def start(self, services: InvocationServices, cancel_event: ThreadEvent, profile
6060

6161
def run(self, queue_item: SessionQueueItem):
6262
"""Run the graph"""
63-
# Loop over invocations until the session is complete or canceled
63+
# Exceptions raised outside `run_node` are handled by the processor.
6464

6565
self._on_before_run_session(queue_item=queue_item)
6666

67+
# Loop over invocations until the session is complete or canceled
6768
while True:
69+
# TODO(psyche): Sessions only support errors on nodes, not on the session itself. When an error occurs outside
70+
# node execution, it bubbles up to the processor where it is treated as a queue item error.
71+
#
72+
# Nodes are pydantic models. When we prepare a node in `session.next()`, we set its inputs. This can cause a
73+
# pydantic validation error. For example, consider a resize image node which has a constraint on its `width`
74+
# input field - it must be greater than zero. During preparation, if the width is set to zero, pydantic will
75+
# raise a validation error.
76+
#
77+
# When this happens, it breaks the flow before `invocation` is set. We can't set an error on the invocation
78+
# because we didn't get far enough to get it - we don't know its id. Hence, we just set it as a queue item error.
79+
6880
invocation = queue_item.session.next()
6981
if invocation is None or self._cancel_event.is_set():
7082
break
@@ -77,7 +89,7 @@ def run(self, queue_item: SessionQueueItem):
7789
def run_node(self, invocation: BaseInvocation, queue_item: SessionQueueItem):
7890
"""Run a single node in the graph"""
7991
try:
80-
# Any unhandled exception is an invocation error & will fail the graph
92+
# Any unhandled exception in this scope is an invocation error & will fail the graph
8193
with self._services.performance_statistics.collect_stats(invocation, queue_item.session_id):
8294
self._on_before_run_node(invocation, queue_item)
8395

0 commit comments

Comments
 (0)