Skip to content

fix: prevent page crash when creating invalid node connections in agent editor#68

Open
skyvast404 wants to merge 1 commit intomainfrom
fix/agent-editor-crash-on-invalid-connection
Open

fix: prevent page crash when creating invalid node connections in agent editor#68
skyvast404 wants to merge 1 commit intomainfrom
fix/agent-editor-crash-on-invalid-connection

Conversation

@skyvast404
Copy link
Collaborator

Summary

  • Add defensive validation in onConnect handler: check source/target nodes exist, prevent self-loops, and wrap the entire handler in try/catch to gracefully handle unexpected errors
  • Wrap BuilderCanvas with the project's existing ErrorBoundary component so that graph rendering errors are isolated to the canvas area instead of crashing the entire page

Closes #58

Root Cause

The onConnect handler in builderStore.ts had no validation or error handling. When users created invalid connections between nodes (e.g. connecting incompatible node types), errors thrown by determineEdgeTypeAndRouteKey or addEdge would propagate uncaught, causing a React render crash that took down the full page. There was also no ErrorBoundary around the BuilderCanvas component.

Test plan

  • Create valid connections between nodes — should work as before
  • Try creating invalid or unusual connections — page should not crash
  • If a rendering error occurs in the canvas, ErrorBoundary should show fallback UI with "Try again" button
  • Toolbar and sidebar should remain functional even if canvas encounters an error

Made with Cursor

…nt editor

- Add defensive checks in onConnect: validate source/target exist, prevent
  self-loops, and wrap entire handler in try/catch
- Wrap BuilderCanvas with ErrorBoundary so graph editor errors don't crash
  the full page

Closes #58

Made-with: Cursor
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] 智能体编辑错误后可能会使页面挂掉

2 participants