Skip to content

fix(playwright): make context cleanup idempotent - #1859

Merged
9aoy merged 5 commits into
mainfrom
9aoy/fix-playwright-cleanup-race
Sep 17, 2026
Merged

9aoy merged 5 commits into
mainfrom
9aoy/fix-playwright-cleanup-race

Conversation

@9aoy

@9aoy 9aoy commented Sep 17, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • serialize Playwright context cleanup behind a shared promise
  • serialize trace finalization and browser release as a second cleanup phase
  • preserve staged traces when context.close() fails before the runner marks the test failed
  • prevent cleanup retries from invoking Playwright close/finalize operations concurrently

The existing context-close failure regression test exercises the re-entrant cleanup path.

This fixes cleanup races and failure-path resource handling. It does not claim to cancel arbitrary Playwright promises after a generic test timeout; Playwright APIs do not expose a common cancellation mechanism for that case.

Validation

  • rslint packages/playwright/src/fixture.ts passed
  • git diff --check passed
  • targeted e2e passed: finalizes Playwright trace when context close fails
  • repository hooks remain blocked by the existing global core.hooksPath and pnpm symlink setup

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 49728dfa52

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread packages/playwright/src/fixture.ts
@github-actions

github-actions Bot commented Sep 17, 2026

Copy link
Copy Markdown

Rsdoctor Bundle Diff Analysis

Found 13 projects in monorepo, 1 project with changes.

📊 Quick Summary
Project Total Size Change
adapter-rsbuild 6.1 KB 0
adapter-rspack 12.4 KB 0
adapter-rslib 51.1 KB 0
browser 1.1 MB 0
browser-react 6.4 KB 0
coverage-istanbul 20.1 KB 0
coverage-v8 82.2 KB 0
playwright 53.8 KB 📈 +796.0 B (+1.5%)
browser/client 79.6 KB 0
core/browser 645.2 KB 0
core/main 2.0 MB 0
vscode/extension 1.3 MB 0
vscode/worker 18.4 KB 0
📋 Detailed Reports (Click to expand)

📁 playwright

Path: packages/playwright/.rsdoctor/rsdoctor-data.json

📌 Baseline Commit: f5796e465f | PR: #1857

Metric Current Baseline Change
📊 Total Size 53.8 KB 53.0 KB +796.0 B (+1.5%)
📄 JavaScript 53.8 KB 53.0 KB +796.0 B (+1.5%)
🎨 CSS 0 B 0 B 0
🌐 HTML 0 B 0 B 0
📁 Other Assets 0 B 0 B 0

📦 Download Diff Report: playwright Bundle Diff

Generated by Rsdoctor GitHub Action

…ed failure

When context.close() throws during onTestFinished for an otherwise
passing test, the runner marks the test failed only after the cleanup
promise rejects, then invokes onTestFailed. The cached rejected promise
must still trigger finishContextCleanup(false) so retain-on-failure
traces are promoted from staging and the retained browser is released.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 12ab2f5a71

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread packages/playwright/src/fixture.ts Outdated

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 190bbe98a4

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread packages/playwright/src/fixture.ts
@9aoy
9aoy merged commit a915d80 into main Sep 17, 2026
10 checks passed
@9aoy
9aoy deleted the 9aoy/fix-playwright-cleanup-race branch September 17, 2026 10:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant