Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion crawl4ai/async_webcrawler.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,17 @@ async def close(self):
await self.crawler_strategy.__aexit__(None, None, None)

async def __aenter__(self):
return await self.start()
try:
return await self.start()
except Exception:
# Ensure partially-initialised Playwright driver is cleaned up
# when browser launch fails inside __aenter__. Without this,
# each failed attempt leaks a live `node run-driver` child. (#2155)
try:
await self.close()
except Exception:
pass
raise

async def __aexit__(self, exc_type, exc_val, exc_tb):
await self.close()
Expand Down