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(platform/builder): Add heartbeat mechanism #8665

Conversation

aarushik93
Copy link
Contributor

@aarushik93 aarushik93 commented Nov 15, 2024

The builder eventually looses connection with our websocket backend, after a few minutes of inactivity.
This PR addes a heartbeat mechanism to allow the connection to remain in the background even with no user activitiy.

Changes 🏗️

The frontend sends a ping and backend responds with a pong

Checklist 📋

For code changes:

  • I have clearly listed my changes in the PR description
  • I have made a test plan
  • I have tested my changes according to the test plan:
    • ...
Example test plan
  • Create from scratch and execute an agent with at least 3 blocks
  • Import an agent from file upload, and confirm it executes correctly
  • Upload agent to marketplace
  • Import an agent from marketplace and confirm it executes correctly
  • Edit an agent from monitor, and confirm it executes correctly

For configuration changes:

  • .env.example is updated or already compatible with my changes
  • docker-compose.yml is updated or already compatible with my changes
  • I have included a list of my configuration changes in the PR description (under Changes)
Examples of configuration changes
  • Changing ports
  • Adding new services that need to communicate with each other
  • Secrets or environment variable changes
  • New or infrastructure changes such as databases

@github-actions github-actions bot added platform/frontend AutoGPT Platform - Front end platform/backend AutoGPT Platform - Back end size/m labels Nov 15, 2024
Copy link

netlify bot commented Nov 15, 2024

Deploy Preview for auto-gpt-docs ready!

Name Link
🔨 Latest commit cc608c4
🔍 Latest deploy log https://app.netlify.com/sites/auto-gpt-docs/deploys/67375109b8eb99000805f546
😎 Deploy Preview https://deploy-preview-8665--auto-gpt-docs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link

netlify bot commented Nov 15, 2024

Deploy Preview for auto-gpt-docs canceled.

Name Link
🔨 Latest commit 8360d91
🔍 Latest deploy log https://app.netlify.com/sites/auto-gpt-docs/deploys/673b597841a60a0008ac3893

@aarushik93 aarushik93 changed the title add heartbeat mechanism fix(platform/builder): Add heartbeat mechanism Nov 18, 2024
@aarushik93 aarushik93 marked this pull request as ready for review November 18, 2024 14:06
@aarushik93 aarushik93 requested a review from a team as a code owner November 18, 2024 14:06
@aarushik93 aarushik93 requested review from Pwuts and kcze and removed request for a team November 18, 2024 14:06
Copy link

PR Reviewer Guide 🔍

Here are some key observations to aid the review process:

⏱️ Estimated effort to review: 2 🔵🔵⚪⚪⚪
🧪 No relevant tests
🔒 No security concerns identified
⚡ Recommended focus areas for review

Error Handling
The heartbeat timeout reconnection logic may cause connection flapping if the server is temporarily slow to respond. Consider implementing exponential backoff for reconnection attempts.

Race Condition
Multiple simultaneous reconnection attempts could occur if heartbeat timeout and onclose handler both trigger reconnects. Consider adding a reconnection state flag.

Resource Leak
The heartbeat interval and timeout timers should be cleared when the websocket connection is closed or encounters an error to prevent memory leaks.

@aarushik93 aarushik93 merged commit 8fccf2e into dev Nov 18, 2024
17 checks passed
@aarushik93 aarushik93 deleted the aarushikansal/open-2038-builder-looses-websocket-connection-when-builder-is-open-for branch November 18, 2024 16:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
platform/backend AutoGPT Platform - Back end platform/frontend AutoGPT Platform - Front end Review effort [1-5]: 2 size/m
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants