autogen icon indicating copy to clipboard operation
autogen copied to clipboard

Fix: Catch TargetClosedError in PlaywrightController.sleep() to avoid crashes on download-triggered page closes

Open oscarvdl opened this issue 1 year ago • 0 comments

Why are these changes needed?

This PR fixes a crash that occurs when using MultimodalWebSurfer in scenarios where a click triggers a file download.
After the download is initiated, Playwright may close the page or context, leading to a TargetClosedError during sleep() in PlaywrightController.

The previous implementation of sleep() did not handle these closures, causing the agent to crash unexpectedly.

This PR adds safe exception handling for TargetClosedError and PlaywrightError during sleep(), ensuring that the agent can continue operating gracefully even if the page closes.

Related issue number

Closes #6413

Checks

oscarvdl avatar Apr 27 '25 19:04 oscarvdl