Implement browser restart functionality on disconnection and enhance retry logic in discovery #2054
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.
This pull request introduces robust handling for browser disconnections during snapshot discovery. The main changes ensure that the browser is automatically restarted if it becomes disconnected or crashes, improving reliability for snapshot operations and retries. Additionally, the default behavior now retries failed snapshot discoveries up to three times. Comprehensive tests have been added to verify browser restart logic and retry behavior.
Browser reliability improvements:
restart()method to theBrowserclass to force-close, reset state, and relaunch the browser instance after disconnection. (packages/core/src/browser.js)page()method to automatically restart the browser if it is disconnected before creating a new page. (packages/core/src/browser.js)Snapshot retry enhancements:
discovery.retrytotrue, enabling up to three retries for snapshot discovery failures by default. (packages/core/src/config.js)createDiscoveryQueueto detect browser/session disconnection errors and restart the browser before retrying a snapshot. (packages/core/src/discovery.js,packages/core/src/utils.js) [1] [2]Testing and validation:
page(), and retrying snapshots with browser restart on connection errors. (packages/core/test/discovery.test.js)