Skip to content

Conversation

@mrubens
Copy link
Collaborator

@mrubens mrubens commented Sep 3, 2025

Important

Allow infinite retry attempts in SocketTransport by setting maxInitialAttempts to Infinity and adjusting connection state handling.

  • Behavior:
    • Set maxInitialAttempts to Infinity in SocketTransport to allow infinite retry attempts.
    • Removed logic that set connectionState to FAILED after exhausting retry attempts.
    • Adjusted error logging to reflect unexpected errors in the connection loop.
  • Logging:
    • Removed max attempt count from connection attempt logs in connectWithRetry().
    • Changed reconnect_failed event to set connectionState to RETRYING instead of FAILED.

This description was created by Ellipsis for 989fb2e. You can customize this summary. It will automatically update as commits are pushed.

@mrubens mrubens requested review from cte and jr as code owners September 3, 2025 06:34
@dosubot dosubot bot added the size:S This PR changes 10-29 lines, ignoring generated files. label Sep 3, 2025
@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label Sep 3, 2025
Copy link

@roomote roomote bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for your contribution! I've reviewed the changes and found several issues that need attention before this can be merged.


private readonly retryConfig: RetryConfig = {
maxInitialAttempts: 10,
maxInitialAttempts: Infinity,
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is setting this to Infinity intentional? The while loop in connectWithRetry() will never exit naturally now, which could lead to resource exhaustion if the connection continuously fails. Consider:

  1. Making this configurable through the constructor's retryConfig parameter
  2. Adding a mechanism to cancel retry attempts (e.g., an abort signal)
  3. Implementing exponential backoff with a maximum retry duration instead of infinite attempts

} catch (error) {
console.error(
`[SocketTransport] Initial connection attempts failed: ${error instanceof Error ? error.message : String(error)}`,
`[SocketTransport] Unexpected error in connection loop: ${error instanceof Error ? error.message : String(error)}`,
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This error message might be misleading now. With infinite retries, errors in the connection loop aren't necessarily "unexpected" anymore. Could we update this to be more descriptive, like "Error in connection retry loop" or "Connection retry loop terminated unexpectedly"?

console.log(
`[SocketTransport] Connection attempt ${this.retryAttempt + 1} / ${this.retryConfig.maxInitialAttempts}`,
)
console.log(`[SocketTransport] Connection attempt ${this.retryAttempt + 1}`)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With maxInitialAttempts now set to Infinity, this while condition will always be true. Should we add an additional exit condition here, such as checking for a cancellation signal or a maximum retry duration?

Also, the removed code that threw an error after max attempts provided a clear exit condition. Without it, the only way to exit this loop is through a successful connection or an unexpected error.


// Socket.IO has exhausted its reconnection attempts
// The connection is now permanently failed until manual intervention
this.connectionState = ConnectionState.RETRYING
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is setting the state to RETRYING here intentional? Socket.IO has already exhausted its reconnection attempts at this point. This might confuse consumers checking the connection state, as it implies retrying is still happening when it's not. Should this remain as FAILED or perhaps a new state like AWAITING_MANUAL_RECONNECT?

@mrubens mrubens merged commit f8973d9 into main Sep 3, 2025
18 of 19 checks passed
@mrubens mrubens deleted the socket_transport_never_give_up branch September 3, 2025 06:47
@github-project-automation github-project-automation bot moved this from Triage to Done in Roo Code Roadmap Sep 3, 2025
@github-project-automation github-project-automation bot moved this from New to Done in Roo Code Roadmap Sep 3, 2025
@hannesrudolph hannesrudolph added the Issue/PR - Triage New issue. Needs quick review to confirm validity and assign labels. label Sep 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Issue/PR - Triage New issue. Needs quick review to confirm validity and assign labels. lgtm This PR has been approved by a maintainer size:S This PR changes 10-29 lines, ignoring generated files.

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

3 participants