rubber-blueR
Apify & Crawleeโ€ข3y agoโ€ข
10 replies
rubber-blue

Error Target page, context or browser closed

Hello fellow developers,

I'm facing a consistent issue with Playwright in the Crawlee library context. Every time I perform an async operation on a locator instance, the page unexpectedly closes.

Here's the simplified code where the issue is evident:

const doesContainAllParts: AlertsProximityAnalyzerComparator<
  Frame | Page
> = async (element) => {
  try {
    const test = element.locator('body');
    const result = await test.count();  // Page closes unexpectedly here

    return result > 0;
  } catch (error) {
    console.error('Error in doesContainAllParts:', error);
    throw error;
  }
};


The issue specifically happens at the line
const result = await test.count()
. Each time this line executes, the page closes, leading to the failure of the operation.

Some key points:
- The problem consistently occurs every time this code is executed.
- I'm using the latest versions of Playwright and Crawlee.
- The issue seems to be tied to the
await
operation on the locator instance.

I'm stumped as to why this is happening. Is this a known issue with Playwright or Crawlee, or could there be something wrong with my implementation? Any insights, suggestions, or similar experiences would be incredibly helpful.

Thanks a lot in advance for any assistance!

PS I'm adding a video with settings headless: false to show you how it looks

PSS And here is disscussion on github with more details: https://github.com/apify/crawlee/discussions/2185
GitHub
Hello everyone, I'm encountering a consistent issue with Playwright in the context of the Crawlee library. Each time I perform an async operation on a locator instance, specifically using await...
Consistent Page Closure Issue in Playwright Crawler (Crawlee) on As...
Was this page helpful?