diff --git a/src/backend/langflow/interface/custom/custom_component.py b/src/backend/langflow/interface/custom/custom_component.py index 233d99186..b03e8a560 100644 --- a/src/backend/langflow/interface/custom/custom_component.py +++ b/src/backend/langflow/interface/custom/custom_component.py @@ -133,8 +133,8 @@ class CustomComponent(Component): def load_flow(self, flow_id: UUID = None): from langflow.processing.process import build_sorted_vertices_with_caching - with get_session() as session: - data_graph = flow.data if (flow := session.get(Flow, flow_id)) else None + session = next(get_session()) + data_graph = flow.data if (flow := session.get(Flow, flow_id)) else None if not data_graph: raise ValueError(f"Flow {flow_id} not found") return build_sorted_vertices_with_caching(data_graph)