fix(browsers): Close pages that give error

This was causing the browser and the whole code to stand still.
This commit is contained in:
Karim shoair
2026-01-11 18:34:13 +02:00
parent 32f4f2adf4
commit d5b9ed11b2
3 changed files with 8 additions and 2 deletions
@@ -158,6 +158,8 @@ class DynamicSession(SyncSession, DynamicSessionMixin):
except Exception as e:
page_info.mark_error()
page_info.page.close()
self.page_pool.pages.remove(page_info)
raise e
@@ -298,4 +300,6 @@ class AsyncDynamicSession(AsyncSession, DynamicSessionMixin):
except Exception as e: # pragma: no cover
page_info.mark_error()
await page_info.page.close()
self.page_pool.pages.remove(page_info)
raise e
+4
View File
@@ -250,6 +250,8 @@ class StealthySession(SyncSession, StealthySessionMixin):
except Exception as e:
page_info.mark_error()
page_info.page.close()
self.page_pool.pages.remove(page_info)
raise e
@@ -467,4 +469,6 @@ class AsyncStealthySession(AsyncSession, StealthySessionMixin):
except Exception as e: # pragma: no cover
page_info.mark_error()
await page_info.page.close()
self.page_pool.pages.remove(page_info)
raise e
-2
View File
@@ -1,5 +1,3 @@
"""Crawler engine that orchestrates the crawling process."""
import json
import anyio