oscarotero / Embed

Get info from any web service or page
MIT License
2.09k stars 310 forks source link

Large quantities of embed-cookies-{uid} are being created, but not deleted? #534

Closed tim-digitalastronaut closed 5 months ago

tim-digitalastronaut commented 5 months ago

I've recently run into issues where no user sessions were being created on the server due to the fact that the /temp folder used up all available memory. After inspecting the contents of the folder, we noticed a huge quantity (0.5 mln) files names embed-cookie-{uid}.txt.

After reviewing the code for your plugin, and after taking a look at the \embed\src\Http\CurlDispatcher.php file's constructor, it would seem that this is the source of the issue. I'm assuming that these .txt files are being created in the temporary storage, but are never being deleted, or maybe only after a very long time?

For now we've cleared out the excess of files in our /temp folder. But obviously we'll encounter the same issue again in the foreseeable future.

oscarotero commented 5 months ago

yes, cookies file is created here: https://github.com/oscarotero/Embed/blob/8632aaa00b35de05de89988632bee7e7392b032e/src/Http/CurlDispatcher.php#L93 but it's not deleted.

But this is just one file with a specific name "embed-cookies.txt", not a bunch of files with uid. So I don't know why do you get that.

tim-digitalastronaut commented 5 months ago

I've encountered the issue with a Craft CMS Plugin that's using your code as a dependency. I'm assuming that they're the ones who've added the {uid}. This is the actual line in the code:

$cookies = str_replace('//', '/', sys_get_temp_dir().'/embed-cookies-'.uniqid().'.txt');

I've raised the same concern on their Github. So you can close this one. I'm sorry for the confusion and I thank you for a swift response.