Skip to content
← Back to activity

Immutable solution version

PlaywrightCrawler hangs infinitely when closing page

Version 2Sign in to save

Complete solution

Shows how to fix playwrightCrawler hangs infinitely when closing page. Use it when you hit this exact problem. Skip it when your error message or symptom looks different.

TL;DR

[barjin (maintainer)]: The crawler hang when a page refuses to close was fixed by PRs 4108 and 4116: the browser pool now handles page-close timeouts itself and retires the browser when a close never settles, instead of holding a live browser with stuck page slots until the run ends.

Steps

  1. [barjin (maintainer)]: The crawler hang when a page refuses to close was fixed by PRs 4108 and 4116: the browser pool now handles page-close timeouts itself and retires the browser when a close never settles, instead of holding a live browser with stuck page slots until the run ends.

When to use

You are seeing this: Crawlee - ### Which package is this bug report for? Use this skill when you run into "PlaywrightCrawler hangs infinitely when closing page".

When not to use

If your error message or symptom does not match what is described above, this is probably not your fix. Search for your exact error text instead of forcing this one to fit.

Versions

No specific versions are mentioned in the source material, so treat the fix as generally applicable and check the examples against whatever you have installed.

Why this happens

The original report does not dig into a root cause. It documents the symptom and the fix that resolved it.

Sources

  • https://github.com/apify/crawlee/issues/1829

Evidence

In gh:apify/crawlee#1829 (https://github.com/apify/crawlee/issues/1829), the issue reported: ### Which package is this bug report for? If unsure which one to select, leave blank @crawlee/playwright (PlaywrightCrawler) ### Issue description Thread: https://apifier.slack.com/archives/CD0SF6KD4/p1677189716880559 This exact line hangs forever (even for hours) https://github.com/apify/crawlee/blob/8ab159bd4c88e2b1ad730ffe524309e823da7857/packages/browser-crawler/src/internals/browser-crawler.ts#L436 ### Code sample ```TypeScript // The code is pretty standard PlaywrightCrawler. The verified answer: [barjin (maintainer)]: The crawler hang when a page refuses to close was fixed by PRs 4108 and 4116: the browser pool now handles page-close timeouts itself and retires the browser when a close never settles, instead of holding a live browser with stuck page slots until the run ends.

By @issueatlas · Version 2 · Exact version

Embed this skill

Add this card to a website or documentation page. It links to the current skill on Vectle.

<a href="https://vectle.com/skills/skl_UKZQXJoZ8rtxHHFsZd8Bjg" style="display:inline-block;padding:12px 16px;border:1px solid #d8ddd3;border-radius:8px;color:#194d35;text-decoration:none;font:14px/1.5 system-ui,sans-serif">PlaywrightCrawler hangs infinitely when closing page <span>— Vectle</span></a>

PlaywrightCrawler hangs infinitely when closing page | Vectle