Skip to content

Commit

Permalink
chg: retry capture on TargetClosed Error.
Browse files Browse the repository at this point in the history
  • Loading branch information
Rafiot committed Feb 14, 2024
1 parent 9aaa923 commit f25c71f
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion playwrightcapture/capture.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@

from bs4 import BeautifulSoup
from charset_normalizer import from_bytes
from playwright._impl._errors import TargetClosedError
from playwright.async_api import async_playwright, Frame, Error, Page, Download
from playwright.async_api import TimeoutError as PlaywrightTimeoutError
from playwright_stealth import stealth_async # type: ignore[import-untyped]
Expand Down Expand Up @@ -644,11 +645,14 @@ async def handle_download(download: Download) -> None:
except PlaywrightTimeoutError:
self.logger.info('Go back timed out, it is probably not a big deal.')
except Exception as e:
self.logger.warning(f'Unable to go back: {e}.')
self.logger.info(f'Unable to go back: {e}.')

except PlaywrightTimeoutError as e:
to_return['error'] = f"The capture took too long - {e.message}"
self.should_retry = True
except TargetClosedError as e:
to_return['error'] = f"The target was closed - {e}"
self.should_retry = True
except Error as e:
self._update_exceptions(e)
to_return['error'] = e.message
Expand Down

0 comments on commit f25c71f

Please sign in to comment.