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

Fix for data directory not being cleared during browser.close() panic #991

Merged
merged 5 commits into from
Aug 3, 2023

Conversation

ankur22
Copy link
Collaborator

@ankur22 ankur22 commented Aug 2, 2023

Description of changes

While testing for another change, it became apparent that the panic when working with browser.close() would prevent any of the remaining data directories from being cleaned up in the temporary directory. Instead of panicking, we're going to log an error and carry on with rest of the process to try and close the subprocess and eventually delete the data directory. This change does indeed bring about the behaviour we want even when the context has been closed.

Checklist

While testing for another change, it became apparent that the panic
when working with browser.close() would prevent any of the remaining
data directories from being cleaned up in the temporary directory.
Instead of panicking, we're going to log an error and carry on with
rest of the process to try and close the subprocess and eventually
delete the data directory. This change does indeed bring about the
behaviour we want even when the context has been closed.
There will be two temp clean dir tests. We need them to not look at
what each other are creating and cause the test to pass/fail. So the
current test will need to write to a new dir that is different to what
the new test will write to.
When the context is closed before we call browser.close() used to
cause a panic on the cdp command to close the browser. Since we've
changed this to log instead of panic, we just need to make sure that
the data dir does indeed get removed when the cdp command fails.
Copy link
Member

@inancgumus inancgumus left a comment

Choose a reason for hiding this comment

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

LGTM. Thanks for working on this and fixing the issues. And also adding one more test 👏 Could you consider my suggestions? My suggestions also apply to the second test. Thanks!

tests/browser_test.go Outdated Show resolved Hide resolved
tests/browser_test.go Outdated Show resolved Hide resolved
1. Work with MkdirTemp to avoid dir name collisions.
2. Defer the cleanup before checking the error on MkdirTemp.
3. Work with RemoveAll to cleanup sub dirs and files incase the test
fails so that the cleanup still occurs as expected.

Resolves: #991 (comment)
Resolves: #991 (comment)
Copy link
Member

@inancgumus inancgumus left a comment

Choose a reason for hiding this comment

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

👍

@ankur22 ankur22 merged commit f2cb59a into main Aug 3, 2023
@ankur22 ankur22 deleted the fix/log-clean-dir branch August 3, 2023 12:53
ankur22 added a commit that referenced this pull request Aug 3, 2023
1. Work with MkdirTemp to avoid dir name collisions.
2. Defer the cleanup before checking the error on MkdirTemp.
3. Work with RemoveAll to cleanup sub dirs and files incase the test
fails so that the cleanup still occurs as expected.

Resolves: #991 (comment)
Resolves: #991 (comment)
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.

2 participants