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

Canceling cypress run execution after cy.recordHar was called results in memory leak #292

Open
Rikkun-1 opened this issue May 23, 2023 · 1 comment
Assignees
Labels
Type: enhancement New feature or request.

Comments

@Rikkun-1
Copy link

Rikkun-1 commented May 23, 2023

Description
If you start recording har and then suddenly stop running tests with ctrl + c, this will leave a temporary har file in /tmp.

Expected behaviour
Even though the /tmp folder will be automatically cleared after a system reboot or you can do it manually, is there a way to automatically delete the temporary file on cypress run cancellation?

Thanks for your attention in advance. :)

@Rikkun-1 Rikkun-1 added the Type: bug Something isn't working label May 23, 2023
@derevnjuk
Copy link
Member

@Rikkun-1, to automatically delete the temporary HAR files, you can consider using the disposeOfHar method.

This method is specifically designed to clean up and delete the temporary HAR file. By calling this method on the teardown, you can ensure that the temporary file is removed.

Here's an example of how you can use the disposeOfHar method:

// In your Cypress test file
beforeEach(() => {
  // Start recording HAR
  // ...
});

afterEach(function() {
  // Stop running tests
  // ...

  // Check if the Cypress run was canceled
  if (this.currentTest.state === 'failed') {
    // Delete the temporary HAR file
    cy.disposeOfHar();
  }
});

However, at this moment, there is no way to clean up such files on the unexpected cancellation, as Cypress does not yet support the graceful shutdown. I'm going to convert your report to the feature request if you don't mind.

@derevnjuk derevnjuk added Type: enhancement New feature or request. and removed Type: bug Something isn't working labels Jun 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: enhancement New feature or request.
Projects
None yet
Development

No branches or pull requests

2 participants