Skip to content

[Bug]: UI mode frequently crashes at test finish with "Error: EBUSY: resource busy or locked" #43821

Closed

Description

@refactoreric

Version

1.64.1

Steps to reproduce

I don't have exact reproduction steps, but in rough lines:

I execute the following in the (vscode) terminal:
npx playwright test -c Configuration/playwright.config.ts Areas/PayAndCollect/Tests/discounts.spec.ts --ui

In case it matters: vscode does have the Playwright Test for VSCode extension installed, but I'm using UI mode because the 'show trace' option rarely displays the live trace anymore, and I like to follow the progress.

I suppose the extension in the parent vscode process cannot interfere with the UI mode that I start from the vscode terminal?

Expected behavior

When the test finishes, the UI mode stays opened, and I see the final complete trace. If trace related files were temporarily locked, Playwright retries, to give system processes (virus scanners or other security software?) some time to release locks.

Actual behavior

At the end, a crash occurs:

node:internal/fs/watchers:323
    const error = new UVException({
                  ^

Error: EBUSY: resource busy or locked, watch 'C:\SourceTests\Twinfield\EndToEndTests\TestResults\HTML\trace\uiMode.CYwC_gH1.js'
    at FSWatcher.<computed> (node:internal/fs/watchers:323:19)
    at watch (node:fs:3176:36)
    at createFsWatchInstance (C:\SourceTests\Twinfield\EndToEndTests\node_modules\playwright-core\lib\utilsBundle.js:56597:32)
    at setFsWatchListener (C:\SourceTests\Twinfield\EndToEndTests\node_modules\playwright-core\lib\utilsBundle.js:56628:15)
    at NodeFsHandler._watchWithNodeFs (C:\SourceTests\Twinfield\EndToEndTests\node_modules\playwright-core\lib\utilsBundle.js:56746:16)
    at NodeFsHandler._handleFile (C:\SourceTests\Twinfield\EndToEndTests\node_modules\playwright-core\lib\utilsBundle.js:56802:25)
    at NodeFsHandler._addToNodeFs (C:\SourceTests\Twinfield\EndToEndTests\node_modules\playwright-core\lib\utilsBundle.js:56999:23)
Emitted 'error' event on FSWatcher instance at:
    at FSWatcher._handleError (C:\SourceTests\Twinfield\EndToEndTests\node_modules\playwright-core\lib\utilsBundle.js:57489:12)
    at NodeFsHandler._addToNodeFs (C:\SourceTests\Twinfield\EndToEndTests\node_modules\playwright-core\lib\utilsBundle.js:57006:20) {
  errno: -4082,
  syscall: 'watch',
  code: 'EBUSY',
  path: 'C:\\SourceTests\\Twinfield\\EndToEndTests\\TestResults\\HTML\\trace\\uiMode.CYwC_gH1.js',
  filename: 'C:\\SourceTests\\Twinfield\\EndToEndTests\\TestResults\\HTML\\trace\\uiMode.CYwC_gH1.js'
}

Node.js v26.12.1

Additional context

The test takes 1 minute (when the environment is warmed up), up to 3 minutes, everything looked good, and I was hoping to get some information on API responses from the trace, to further extend the assertions, so it's quite frustrating when the UI mode crashes at the finish line.

Environment

System:
    OS: Windows 11 10.0.22631
    CPU: (16) x64 11th Gen Intel(R) Core(TM) i7-11850H @ 2.50GHz
    Memory: 34.23 GB / 63.67 GB
  Binaries:
    Node: 26.12.1 - C:\Program Files\nodejs\node.EXE
    npm: 11.20.0 - C:\Program Files\nodejs\npm.CMD
  IDEs:
    VSCode: 1.144.0 - C:\Users\Eric.Veltman\AppData\Local\Programs\Microsoft VS Code\bin\code.CMD
  Languages:
    Bash: 5.1.16 - C:\WINDOWS\system32\bash.EXE
  npmPackages:
    @playwright/test: 1.64.1 => 1.64.1

Activity

  1. refactoreric commented on Oct 31, 2026

    @refactoreric
    Author

    Some additional information: It doesn't only happen at test finish. I just had another crash. I clicked the Refresh button in UI mode (after renaming test and adding test steps), and (maybe?) I restarted the test(?), or it already crashed during Refresh(?). Console output:

    node:internal/fs/watchers:323
        const error = new UVException({
                      ^
    
    Error: EBUSY: resource busy or locked, watch 'C:\SourceTests\Twinfield\EndToEndTests\TestResults\HTML\trace\uiMode.html'
        at FSWatcher.<computed> (node:internal/fs/watchers:323:19)
        at watch (node:fs:3176:36)
        at createFsWatchInstance (C:\SourceTests\Twinfield\EndToEndTests\node_modules\playwright-core\lib\utilsBundle.js:56597:32)
        at setFsWatchListener (C:\SourceTests\Twinfield\EndToEndTests\node_modules\playwright-core\lib\utilsBundle.js:56628:15)
        at NodeFsHandler._watchWithNodeFs (C:\SourceTests\Twinfield\EndToEndTests\node_modules\playwright-core\lib\utilsBundle.js:56746:16)
        at NodeFsHandler._handleFile (C:\SourceTests\Twinfield\EndToEndTests\node_modules\playwright-core\lib\utilsBundle.js:56802:25)
        at NodeFsHandler._addToNodeFs (C:\SourceTests\Twinfield\EndToEndTests\node_modules\playwright-core\lib\utilsBundle.js:56999:23)
    Emitted 'error' event on FSWatcher instance at:
        at FSWatcher._handleError (C:\SourceTests\Twinfield\EndToEndTests\node_modules\playwright-core\lib\utilsBundle.js:57489:12)
        at NodeFsHandler._addToNodeFs (C:\SourceTests\Twinfield\EndToEndTests\node_modules\playwright-core\lib\utilsBundle.js:57006:20) {
      errno: -4082,
      syscall: 'watch',
      code: 'EBUSY',
      path: 'C:\\SourceTests\\Twinfield\\EndToEndTests\\TestResults\\HTML\\trace\\uiMode.html',
      filename: 'C:\\SourceTests\\Twinfield\\EndToEndTests\\TestResults\\HTML\\trace\\uiMode.html'
    }
    
    Node.js v26.12.1
    
  2. github-actions commented on Oct 31, 2026

    @github-actions
  3. github-actions commented on Oct 31, 2026

    @github-actions
    Contributor

    Hi, I'm the Playwright bot and I reproduced this on Windows.

    Fixed on main by #43716, but not yet in a stable release. Holding the report files open with exclusive Windows locks crashes UI mode on 1.64.1 with the same EBUSY error and chokidar stack. The current watcher watches directories instead of opening a watch on each file; the same case now passes, including reloading and running tests while those files remain locked.

    This reproduces without VS Code or its extension. It confirms that a file lock is enough to trigger the crash, but does not identify which process holds the files in your environment.

    Reproduction and results

    I temporarily extended should not watch output in tests/playwright-test/ui-mode-test-watch.spec.ts. After one test completed, a fixture-managed PowerShell process created and exclusively locked TestResults\HTML\trace\uiMode.html and uiMode.js beneath the watched test directory:

    $streams = @('uiMode.html', 'uiMode.js') | ForEach-Object {
      [System.IO.File]::Open("TestResults\HTML\trace\$_",
        [System.IO.FileMode]::Create,
        [System.IO.FileAccess]::ReadWrite,
        [System.IO.FileShare]::None)
    }
    [Console]::WriteLine('LOCKED')
    [Console]::ReadLine() | Out-Null
    $streams | ForEach-Object { $_.Dispose() }

    The directory existed before starting UI mode. No watcher errors were simulated. The passing check also edited a test, clicked Reload, and ran it successfully before releasing the locks.

    All runs were on Windows with Node.js 24.22.2, rather than the reported 26.12.1:

    Version / commit Mode Result
    Published 1.64.1 Headless UI Process crashes with EBUSY, errno -4082, watching uiMode.js; same chokidar stack as reported
    #43716 head 82c66e43e2595b8dae8785786af9e38d286bb346 Headless UI Locked-file check passes
    Main deb7e86201e26cb4a8e25191fce5ef2f7a28aa87 (1.65.0-next) Headless UI All 10 UI watch tests pass, including the locked-file check
    Same main commit Headed UI Locked-file check passes

    UI mode uses Chromium; the test body did not launch a browser. Firefox and WebKit were not involved in this file-watcher failure.

    The fix merged as e905d4bd77dff425f981b03df861fed59b50c9dd. No release tag contains it; the latest stable package checked was 1.64.1. No additional source fix is needed for this reproduced failure.

    Triaged on Windows by the Playwright bot - agent run

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions