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

Temporary user data directory not always erased #46

Open
bch36 opened this issue Nov 14, 2024 · 0 comments
Open

Temporary user data directory not always erased #46

bch36 opened this issue Nov 14, 2024 · 0 comments

Comments

@bch36
Copy link

bch36 commented Nov 14, 2024

I've discovered that the temporary user data directory can sometimes be recreated after being deleted after the process is shut down cleanly. It's not consistent--sometimes it happens, sometimes it doesn't. I believe it's a timing issue. I believe what's happening is that after the main process is stopped and the directory is deleted, a child process (Chrome seems to spawn a lot!) will attempt to write something to the directory and thereby recreate it.

This seems to be confirmed by adding a "sleep" statement after stopping the process and before deleting the temporary user data dir. If we wait a few seconds before deleting the directory, it doesn't come back.

I'm happy to submit a pull request if desired, but it seems to be a pretty ugly fix--I just don't know a better way to wait until all the spawned child processes fully shut down.

ProcessInstance.php:

public function close(): void
{
	$this->process->stop();
	$this->process = null;

	sleep(5); // Adding this prevents temporaryUserDataDir from returning after it's removed

	if ($this->temporaryUserDataDir !== null) {
		(new Filesystem())->remove($this->temporaryUserDataDir);
	}
}
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

No branches or pull requests

1 participant