Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: enhance error handling in build_flow and add error handling for Flow build #3259

Merged
merged 2 commits into from
Aug 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion src/backend/base/langflow/api/v1/chat.py
Original file line number Diff line number Diff line change
Expand Up @@ -356,10 +356,23 @@ async def event_generator(queue: asyncio.Queue, client_consumed_queue: asyncio.Q
except asyncio.CancelledError:
vertices_task.cancel()
return
except Exception as e:
if isinstance(e, HTTPException):
send_event("error", {"error": str(e.detail), "statusCode": e.status_code}, queue)
raise e
send_event("error", {"error": str(e)}, queue)
raise e

ids, vertices_to_run, graph = vertices_task.result()
else:
ids, vertices_to_run, graph = await build_graph_and_get_order()
try:
ids, vertices_to_run, graph = await build_graph_and_get_order()
except Exception as e:
if isinstance(e, HTTPException):
send_event("error", {"error": str(e.detail), "statusCode": e.status_code}, queue)
raise e
send_event("error", {"error": str(e)}, queue)
raise e
send_event("vertices_sorted", {"ids": ids, "to_run": vertices_to_run}, queue)
await client_consumed_queue.get()

Expand Down
8 changes: 8 additions & 0 deletions src/frontend/src/utils/buildUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,14 @@ export async function buildFlowVertices({
useFlowStore.getState().setIsBuilding(false);
return true;
}
case "error": {
const errorMessage = data.error;
console.log(data);
onBuildError!("Error Running Flow", [errorMessage], []);
buildResults.push(false);
useFlowStore.getState().setIsBuilding(false);
return true;
}
default:
return true;
}
Expand Down
Loading