fix: add retry and reconnection logic for popup resilience#37
Merged
fix: add retry and reconnection logic for popup resilience#37
Conversation
- Add RetryConfig interface with maxAttempts, baseDelayMs, maxDelayMs, backoffMultiplier - Add calculateBackoffDelay function for exponential backoff - Add isRetryableError to detect recoverable Chrome messaging errors - Add delay utility function - Add comprehensive unit tests 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Add MessagingError class with typed error codes - Add isServiceWorkerError detection helper - Add classifyError for error classification - Add toMessagingError utility for error conversion 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Add sendMessageWithRetry with exponential backoff - Detect service worker termination errors and retry - Handle ERROR response type from background - Fix MessagingError to properly use Error.cause 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Add PopupConnection interface for managed port connections - Add createPopupConnection with automatic reconnection - Implement onDisconnect handler with exponential backoff - Add connection state tracking via callbacks 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Update usePopupPort to use createPopupConnection with reconnection - Add .catch() to captureCurrentTab in useCaptureScreenshot - Add .catch() to getLaunchInfo/clearLaunchInfo in useDisplayModeControl - Add error handling to switchToTab in popup entry - Add fallback to "all" mode when display mode detection fails 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
sendMessagefor handling MV3 service worker terminationProblem
When the popup is opened after a period of inactivity, it sometimes shows nothing. This is caused by:
Changes
Core retry logic (
src/core/retry/)RetryConfiginterface with configurable max attempts, delays, and backoffcalculateBackoffDelayfor exponential backoff calculationisRetryableErrorto detect recoverable Chrome messaging errorsMessaging infrastructure (
src/infrastructure/chrome/)MessagingErrorclass with typed error codessendMessagenow includes automatic retry with exponential backoffcreatePopupConnectionfor managed port connections with auto-reconnectPopup error handling (
src/popup/)usePopupPortnow usescreatePopupConnectionfor resilient connections.catch()handlers to all async operationsTest plan
bun run test- all tests passbun run build- build succeeds🤖 Generated with Claude Code