Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"[firefox-profile] cannot delete profileDir on exit" sporadic issue on Windows #31324

Open
MikeMcC399 opened this issue Mar 19, 2025 · 0 comments

Comments

@MikeMcC399
Copy link
Contributor

MikeMcC399 commented Mar 19, 2025

Current behavior

When running against Firefox under Windows, Cypress may sporadically fail to delete the temporary Firefox profile on exit from the test.

An error message similar to the following is output:

[firefox-profile] cannot delete profileDir on exit C:\Users\mikem\AppData\Roaming\Cypress\cy\production\browsers\firefox-stable\run-28020 Error: EPERM: operation not permitted, unlink 'C:\Users\mikem\AppData\Roaming\Cypress\cy\production\browsers\firefox-stable\run-28020\rust_mozprofilejSaa27\cookies.sqlite-shm'

  errno: -4048,
  code: 'EPERM',
  syscall: 'unlink',

The name of the file varies and may include for instance:

  • cookies.sqlite-shm
  • favicons.sqlite-shm

The issue does not prevent Cypress from running. In most cases the temporary profile is removed in a following run.

Since the issue occurs only sporadically it may be a timing / synchronization problem.

Running under GitHub Actions in two identical test runs:

Desired behavior

Cypress should reliably delete any temporary profile created for Firefox at the end of testing.

Test code to reproduce

Execute:

git clone --branch firefox-profile https://github.com/MikeMcC399/cypress-test-tiny
cd cypress-test-tiny
npm ci
rm -rf $APPDATA/Cypress # Windows only

then repeatedly execute:

npx cypress run -s cypress/e2e/spec.cy.js -b firefox

Cypress Version

14.2.0

Node version

v22.14.0 LTS

Operating System

  • Windows 11 24H2
  • Windows Server 2025

Debug Logs

export DEBUG=cypress:server:profilecleaner
$ npx cypress run -b firefox


DevTools listening on ws://127.0.0.1:50753/devtools/browser/7f0f1551-9cd9-4326-ab98-5b66e06dc3f8
  cypress:server:profilecleaner found 0 root level profile matches: [] +0ms
  cypress:server:profilecleaner found 0 profile folders: [] +1ms
  cypress:server:profilecleaner found 0 profile folders: [] +0ms

====================================================================================================

  (Run Starting)

  ┌────────────────────────────────────────────────────────────────────────────────────────────────┐
  │ Cypress:        14.2.0                                                                         │
  │ Browser:        Firefox 136 (headless)                                                         │
  │ Node Version:   v22.14.0 (C:\Program Files\nodejs\node.exe)                                    │
  │ Specs:          2 found (spec-default.cy.js, spec.cy.js)                                       │
  │ Searched:       cypress/e2e/**/*.cy.{js,jsx,ts,tsx}                                            │
  └────────────────────────────────────────────────────────────────────────────────────────────────┘


────────────────────────────────────────────────────────────────────────────────────────────────────

  Running:  spec-default.cy.js                                                              (1 of 2)


  template spec
    √ passes (517ms)


  1 passing (2s)


  (Results)

  ┌────────────────────────────────────────────────────────────────────────────────────────────────┐
  │ Tests:        1                                                                                │
  │ Passing:      1                                                                                │
  │ Failing:      0                                                                                │
  │ Pending:      0                                                                                │
  │ Skipped:      0                                                                                │
  │ Screenshots:  0                                                                                │
  │ Video:        false                                                                            │
  │ Duration:     2 seconds                                                                        │
  │ Spec Ran:     spec-default.cy.js                                                               │
  └────────────────────────────────────────────────────────────────────────────────────────────────┘


────────────────────────────────────────────────────────────────────────────────────────────────────

  Running:  spec.cy.js                                                                      (2 of 2)


  test local demo page
    √ heading (98ms)


  1 passing (129ms)


  (Results)

  ┌────────────────────────────────────────────────────────────────────────────────────────────────┐
  │ Tests:        1                                                                                │
  │ Passing:      1                                                                                │
  │ Failing:      0                                                                                │
  │ Pending:      0                                                                                │
  │ Skipped:      0                                                                                │
  │ Screenshots:  0                                                                                │
  │ Video:        false                                                                            │
  │ Duration:     0 seconds                                                                        │
  │ Spec Ran:     spec.cy.js                                                                       │
  └────────────────────────────────────────────────────────────────────────────────────────────────┘


====================================================================================================

  (Run Finished)


       Spec                                              Tests  Passing  Failing  Pending  Skipped
  ┌────────────────────────────────────────────────────────────────────────────────────────────────┐
  │ √  spec-default.cy.js                       00:02        1        1        -        -        - │
  ├────────────────────────────────────────────────────────────────────────────────────────────────┤
  │ √  spec.cy.js                               125ms        1        1        -        -        - │
  └────────────────────────────────────────────────────────────────────────────────────────────────┘
    √  All specs passed!                        00:02        2        2        -        -        -

[firefox-profile] cannot delete profileDir on exit C:\Users\mikem\AppData\Roaming\Cypress\cy\production\browsers\firefox-stable\run-6780 Error: EPERM: operation not permitted, unlink 'C:\Users\mikem\AppData\Roaming\Cypress\cy\production\browsers\firefox-stable\run-6780\rust_mozprofilewIazdF\cookies.sqlite-shm'
    at unlinkSync (node:fs:1885:11)
    at _unlinkSync (node:internal/fs/rimraf:216:14)
    at fixWinEPERMSync (node:internal/fs/rimraf:308:5)
    at rimrafSync (node:internal/fs/rimraf:202:14)
    at node:internal/fs/rimraf:255:9
    at Array.forEach (<anonymous>)
    at _rmdirSync (node:internal/fs/rimraf:252:7)
    at fixWinEPERMSync (node:internal/fs/rimraf:306:5)
    at rimrafSync (node:internal/fs/rimraf:202:14)
    at node:internal/fs/rimraf:255:9
    at Array.forEach (<anonymous>)
    at _rmdirSync (node:internal/fs/rimraf:252:7)
    at fixWinEPERMSync (node:internal/fs/rimraf:306:5)
    at rimrafSync (node:internal/fs/rimraf:202:14)
    at Object.rmSync (node:fs:1263:10)
    at v._cleanOnExit (<embedded>:1011:95941)
    at process.onExit (<embedded>:1011:94820)
    at process.emit (node:events:530:35)
    at App.<anonymous> (node:electron/js2c/browser_init:2:127161)
    at App.emit (node:events:518:28)
    at g (<embedded>:2886:2340)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {
  errno: -4048,
  code: 'EPERM',
  syscall: 'unlink',
  path: 'C:\\Users\\mikem\\AppData\\Roaming\\Cypress\\cy\\production\\browsers\\firefox-stable\\run-6780\\rust_mozprofilewIazdF\\cookies.sqlite-shm'
}
$ npx cypress run -b firefox


DevTools listening on ws://127.0.0.1:50918/devtools/browser/cbd877b3-a4cb-47f0-ba42-113e163f84fa
  cypress:server:profilecleaner found 0 profile folders: [] +0ms
  cypress:server:profilecleaner found 0 root level profile matches: [] +2ms
  cypress:server:profilecleaner found 1 profile folders: [ 'C:/Users/mikem/AppData/Roaming/Cypress/cy/production/browsers/firefox-stable/run-6780' ] +0ms
  cypress:server:profilecleaner finding process by pid: 6780 +1ms
  cypress:server:profilecleaner removing old profile { pid: 6780, folder: 'C:/Users/mikem/AppData/Roaming/Cypress/cy/production/browsers/firefox-stable/run-6780' } +962ms

====================================================================================================

  (Run Starting)

  ┌────────────────────────────────────────────────────────────────────────────────────────────────┐
  │ Cypress:        14.2.0                                                                         │
  │ Browser:        Firefox 136 (headless)                                                         │
  │ Node Version:   v22.14.0 (C:\Program Files\nodejs\node.exe)                                    │
  │ Specs:          2 found (spec-default.cy.js, spec.cy.js)                                       │
  │ Searched:       cypress/e2e/**/*.cy.{js,jsx,ts,tsx}                                            │
  └────────────────────────────────────────────────────────────────────────────────────────────────┘


────────────────────────────────────────────────────────────────────────────────────────────────────

  Running:  spec-default.cy.js                                                              (1 of 2)


  template spec
    √ passes (442ms)


  1 passing (2s)


  (Results)

  ┌────────────────────────────────────────────────────────────────────────────────────────────────┐
  │ Tests:        1                                                                                │
  │ Passing:      1                                                                                │
  │ Failing:      0                                                                                │
  │ Pending:      0                                                                                │
  │ Skipped:      0                                                                                │
  │ Screenshots:  0                                                                                │
  │ Video:        false                                                                            │
  │ Duration:     1 second                                                                         │
  │ Spec Ran:     spec-default.cy.js                                                               │
  └────────────────────────────────────────────────────────────────────────────────────────────────┘


────────────────────────────────────────────────────────────────────────────────────────────────────

  Running:  spec.cy.js                                                                      (2 of 2)


  test local demo page
    √ heading (108ms)


  1 passing (139ms)


  (Results)

  ┌────────────────────────────────────────────────────────────────────────────────────────────────┐
  │ Tests:        1                                                                                │
  │ Passing:      1                                                                                │
  │ Failing:      0                                                                                │
  │ Pending:      0                                                                                │
  │ Skipped:      0                                                                                │
  │ Screenshots:  0                                                                                │
  │ Video:        false                                                                            │
  │ Duration:     0 seconds                                                                        │
  │ Spec Ran:     spec.cy.js                                                                       │
  └────────────────────────────────────────────────────────────────────────────────────────────────┘


====================================================================================================

  (Run Finished)


       Spec                                              Tests  Passing  Failing  Pending  Skipped
  ┌────────────────────────────────────────────────────────────────────────────────────────────────┐
  │ √  spec-default.cy.js                       00:01        1        1        -        -        - │
  ├────────────────────────────────────────────────────────────────────────────────────────────────┤
  │ √  spec.cy.js                               133ms        1        1        -        -        - │
  └────────────────────────────────────────────────────────────────────────────────────────────────┘
    √  All specs passed!                        00:01        2        2        -        -        -

Other

Firefox version: 136.0.2 (current latest)

Similar issues have been reported under:

cc: @AtofStryker

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

No branches or pull requests

2 participants