Skip to content

Conversation

@prklm10
Copy link
Contributor

@prklm10 prklm10 commented Dec 3, 2025

This pull request introduces robust browser recovery and retry logic to improve reliability when the browser disconnects or crashes during asset discovery and snapshot operations. The main changes add automatic browser restart handling to the Browser class, integrate error-aware retries in the snapshot discovery queue, and enhance the withRetries utility to pass error details to retry callbacks. Comprehensive tests have been added to ensure correct behavior across various failure scenarios.

Browser recovery and retry logic:

  • Added a restart method to the Browser class that force-closes the browser, resets internal state, clears callbacks and sessions, and launches a new browser instance. (packages/core/src/browser.js)
  • Updated the page() method in Browser to automatically restart the browser if it is disconnected before creating a new page. (packages/core/src/browser.js)
  • Enhanced the snapshot discovery queue to detect browser disconnection errors (such as "Browser not connected", "Browser closed", "Session closed", or "Session crashed") and restart the browser before retrying the snapshot. (packages/core/src/discovery.js)
  • Modified the withRetries utility to pass the error object to the onRetry callback, allowing more context-aware retry logic. (packages/core/src/utils.js)

Testing and validation:

  • Added extensive tests for browser restart scenarios and the retry logic, including cases for browser disconnection, session crashes, restart failures, and correct clearing of browser state. Also added tests for the enhanced withRetries utility, covering error passing, async callbacks, and error handling. (packages/core/test/discovery.test.js, packages/core/test/utils.test.js) [1] [2]

@prklm10 prklm10 requested a review from a team as a code owner December 3, 2025 06:39
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.

2 participants