Skip to content

feat: add retry with exponential backoff and progress feedback (#12)#20

Open
rafabd1 wants to merge 1 commit intomainfrom
feature/issue-12-retry-backoff-progress
Open

feat: add retry with exponential backoff and progress feedback (#12)#20
rafabd1 wants to merge 1 commit intomainfrom
feature/issue-12-retry-backoff-progress

Conversation

@rafabd1
Copy link
Owner

@rafabd1 rafabd1 commented Mar 14, 2026

Feature: Add retry with exponential backoff and progress feedback (#12)

Closes #12

Problem

When I2P tunnels are degraded or the peer is temporarily unavailable, initiate_session fails immediately with a generic error. This results in:

  1. Poor user experience: Users see an error immediately and must manually retry
  2. No progress feedback: Users don't know if the app is working or stuck
  3. No automatic recovery: Temporary network issues cause permanent failure
  4. Uninformative errors: Generic messages don't help users understand what's happening

This is particularly problematic on I2P, where tunnel establishment can take 30-60s and tunnels often degrade temporarily.

Solution

Implement retry with exponential backoff and progress feedback:

  1. Retry loop with exponential backoff:

    • Maximum 5 attempts before giving up
    • Backoff delays: 2s, 4s, 8s, 16s between retries
    • Generates new ephemeral keys for each attempt (forward security)
  2. Progress events:

    • connection_progress: Emitted before each attempt with attempt, max_attempts, and status
    • Allows frontend to show progress bar or status to user
  3. Error events:

    • connection_error: Emitted after each failed attempt with descriptive message
    • Frontend can display errors to help users understand what's happening
  4. Timeouts:

    • 60s timeout for ACK response (configurable)
    • Prevents indefinite hanging on unresponsive peers
  5. Clear final error:

    • After all retries, emit final error explaining the situation
    • Suggests possible causes (peer offline, tunnel degraded)

Implementation details

  • Retry attempts wrap the entire handshake process (connection + send init + receive ack)
  • Each retry generates new ephemeral keys for perfect forward security
  • Exponential backoff with 2^n seconds (capped at 16s)
  • All operations wrapped in proper error handling to ensure retries work correctly
  • Events use standard Tauri event system for frontend integration

- Add retry loop with max 5 attempts in initiate_session
- Exponential backoff: 2s, 4s, 8s, 16s between attempts
- Emit connection_progress event with attempt number and status
- Emit connection_error events with descriptive messages for each failure
- Generate new ephemeral keys for each retry attempt
- Add 60s timeout for ACK response
- Provide clear error messages to users about connection failures

This implements issue #12 to improve user experience when I2P tunnels are
degraded. Users now see progress updates and the app automatically retries
with increasing delays instead of failing immediately.
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.

initiate_session: add retry with backoff and progress feedback

1 participant