Skip to content

[Bug]: [Regression] BrowserContext.close() hangs during teardown with recordHar after upgrading from 1.61.0 to 1.62.1 #42231

Description

@jakubdmuch-fdb

Version

1.62.1

Steps to reproduce

Version

  • Good: Playwright 1.61.0
  • Bad: Playwright 1.62.1
  • Node.js: 24.18.1
  • OS/container:

Description

After upgrading Playwright from 1.61.0 to 1.62.1,
browser context teardown may hang until the test timeout when HAR recording is enabled.

The timeout occurs in a global fixture cleanup after the test body has completed.
The test itself may pass, but context.close() does not finish.

HAR configuration

recordHar: {
  path: 'network.har',
  mode: 'full',
  content: 'embed',
}

The issue disappears when HAR recording is disabled.

We are also testing:
recordHar: {
  path: 'network.har',
  mode: 'minimal',
  content: 'attach',
}

but also the same bug. ---> Tearing down "cleanAfterTest" exceeded the test timeout of 60000ms

### Expected behavior

browserContext.close() should finish within a reasonable time after the test completes.

### Actual behavior

fail:  Tearing down "cleanAfterTest" exceeded the test timeout of 60000ms

Tearing down "cleanAfterTest" exceeded the test timeout of 60000ms.
    attachment #1: screenshot (image/png) ──────────────────────────────────────────────────────────
    test-results/landing_sessionTimeout/test-failed-1.png
    ────────────────────────────────────────────────────────────────────────────────────────────────
    Error Context: test-results/landing_sessionTimeout/error-context.md
    attachment #3: trace (application/zip) ─────────────────────────────────────────────────────────
    test-results/landing_sessionTimeout/trace.zip
    Usage:
        npx playwright show-trace test-results/landing_sessionTimeout/trace.zip


### Additional context

The issue is reproducible in our GitLab CI pipeline.

The test body completes, but the global fixture teardown hangs while closing the browser context:

Tearing down "cleanAfterTest" exceeded the test timeout of 60000ms

The problem appeared after upgrading from Playwright 1.61.0 to 1.62.1. The same tests worked with 1.61.0.

HAR configuration that triggers the problem:

```ts
recordHar: {
  path: 'network.har',
  mode: 'full',
  content: 'embed',
}

Disabling HAR recording removes the teardown timeout. We are also testing whether the following lighter configuration avoids the issue:

recordHar: {
  path: 'network.har',
  mode: 'minimal',
  content: 'attach',
}

The CI runner image and Node.js version also changed during the upgrade, so this may involve the combination of Playwright, Node.js, and the runner image.

### Environment

```shell
System: gitlab + 
    OS: Linux 7.0 Ubuntu 24.04.4 LTS 24.04.4 LTS (Noble Numbat)
    CPU: (16) x64 Intel(R) Core(TM) Ultra 9 285H
    Memory: 47.29 GB / 62.25 GB
    Container: Yes
  Binaries:
    Node: 22.14.0
    npm: 10.9.2 
  IDEs:
    Codex: 0.147.0 
  Languages:
    Bash: 5.2.21 
  npmPackages:
    @playwright/test: 1.62.1 => 1.62.1 
    playwright-qase-reporter: 2.6.0 => 2.6.0 
    playwright-slack-report: 1.1.112 => 1.1.112

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions