Skip to content

fix(browsers): Retry the temp directory removal until the browser releases its files - #2239

Open
vdusek wants to merge 4 commits into
masterfrom
fix/browser-temp-dir-removal
Open

vdusek wants to merge 4 commits into
masterfrom
fix/browser-temp-dir-removal

Conversation

@vdusek

@vdusek vdusek commented Sep 16, 2026 •

Copy link
Copy Markdown
Collaborator

PlaywrightPersistentBrowser.close() removed the temp profile directory with one shutil.rmtree(ignore_errors=True) call. On Windows the browser can still hold files there, so the directory leaked silently. The removal now retries (50 × 100 ms) and logs a warning if it never succeeds. close() and the context's close listener both trigger it; a lock makes it run once, and close() waits until it finishes.

Fixes the flaky test_delete_temp_folder_with_close_browser on windows-latest (run 35085779018, run 35991074349).

The crawler state fixes moved to #2255.

✍️ Drafted by Claude Code

@vdusek vdusek added t-tooling Issues with this label are in the ownership of the tooling team. adhoc Ad-hoc unplanned task added during the sprint. labels Sep 16, 2026
@vdusek vdusek self-assigned this Sep 16, 2026
@codecov

codecov Bot commented Sep 16, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.74%. Comparing base (45bb0e2) to head (b0f8dad).

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2239      +/-   ##
==========================================
- Coverage   93.74%   93.74%   -0.01%     
==========================================
  Files         181      181              
  Lines       12884    12897      +13     
==========================================
+ Hits        12078    12090      +12     
- Misses        806      807       +1     
Flag Coverage Δ
unit 93.74% <100.00%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@vdusek vdusek changed the title fix(browsers): Retry the temp directory removal until the browser releases its files fix: Keep the crawler usable after a failed run and retry the browser temp directory removal Sep 16, 2026
@vdusek vdusek changed the title fix: Keep the crawler usable after a failed run and retry the browser temp directory removal fix!: Keep the crawler usable after a failed run and retry the browser temp directory removal Sep 16, 2026
@vdusek vdusek changed the title fix!: Keep the crawler usable after a failed run and retry the browser temp directory removal fix: Keep the crawler usable after a failed run and retry the browser temp directory removal Sep 24, 2026
@vdusek vdusek changed the title fix: Keep the crawler usable after a failed run and retry the browser temp directory removal fix(browsers): Retry the temp directory removal until the browser releases its files Sep 24, 2026
@vdusek
vdusek force-pushed the fix/browser-temp-dir-removal branch from 7579066 to 91ee089 Compare September 24, 2026 12:07
@vdusek
vdusek requested a review from Pijukatel September 24, 2026 13:06
@vdusek
vdusek marked this pull request as ready for review September 24, 2026 13:06
@apify-service-account apify-service-account added the tested Temporary label used only programatically for some analytics. label Sep 24, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

adhoc Ad-hoc unplanned task added during the sprint. t-tooling Issues with this label are in the ownership of the tooling team. tested Temporary label used only programatically for some analytics.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants