From 83707dc837d20938aaa0c02e74070242bb725811 Mon Sep 17 00:00:00 2001 From: dgtlmoon Date: Mon, 31 Aug 2026 13:21:38 +0200 Subject: [PATCH] Puppeteer fetcher - page crash handler (if there wasnt one, it could have crashed the CDP session) --- changedetectionio/content_fetchers/puppeteer.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/changedetectionio/content_fetchers/puppeteer.py b/changedetectionio/content_fetchers/puppeteer.py index 849c21ed2..73adf8d85 100644 --- a/changedetectionio/content_fetchers/puppeteer.py +++ b/changedetectionio/content_fetchers/puppeteer.py @@ -318,6 +318,20 @@ class fetcher(Fetcher): self.browser = None raise + # A renderer crash makes pyppeteer emit Page 'error' (PageError('Page crashed!')). + # pyee re-raises an 'error' emission that has no listener, and that raise escapes into + # Connection._onMessage, whose catch-all disposes the entire connection - so one dead + # tab takes the whole browser with it and every later call reports the misleading + # "Session closed. Most likely the page has been closed." Attaching a listener keeps + # the failure local, named, and recoverable. + self.page_error = None + + def _handle_page_error(e): + self.page_error = e + logger.error(f"[{watch_uuid}] Page error (the renderer likely crashed, often OOM): {e}") + + self.page.on('error', _handle_page_error) + # Add console handler to capture console.log from favicon fetcher #self.page.on('console', lambda msg: logger.debug(f"Browser console [{msg.type}]: {msg.text}"))