Back to all reviewers

Connection resilience patterns

supabase/supabase
Based on 2 comments
Typescript

Implement resilient networking connections with retry mechanisms for all client-service interactions. When establishing connections to external services or databases, include proper retry logic with backoff strategies to handle temporary network instabilities or service unavailability. Monitor connection counts and states across different connection types...

Networking Typescript

Reviewer Prompt

Implement resilient networking connections with retry mechanisms for all client-service interactions. When establishing connections to external services or databases, include proper retry logic with backoff strategies to handle temporary network instabilities or service unavailability. Monitor connection counts and states across different connection types to detect potential issues.

// Example implementation of connection retry logic
const getClientConnection = async (maxRetries = 3, backoffMs = 500): Promise<Connection> => {
  let attempts = 0;
  
  while (attempts < maxRetries) {
    try {
      const connectionString = await getValidConnectionString();
      return new Client(connectionString);
    } catch (error) {
      attempts++;
      if (attempts >= maxRetries) throw error;
      
      console.log(`Connection attempt ${attempts} failed, retrying in ${backoffMs}ms...`);
      await new Promise(resolve => setTimeout(resolve, backoffMs));
      // Exponential backoff for next attempt
      backoffMs *= 2;
    }
  }
}
2
Comments Analyzed
Typescript
Primary Language
Networking
Category

Source Discussions