Open stuartcusackie opened 1 year ago
@stuartcusackie is this site a multi-site?
@edalzell Yes indeed. This is happening on a multi-site. It doesn't seem to happen on single sites - still checking my error logs...
I'm using DO Spaces to store my Glide manipulations and I see this error when using SSG and too many workers. If I use a single worker, my site builds fine, but the more workers I add the more likely I am to encounter a "Unable to set visibility for file" error. The images that tend to cause this error are ones commonly found on most pages in my website. My hunch is that there's some kind of read/write conflict happening when multiple workers try to simultaneously manipulate the same image. I dunno if this same cause could relate to multi-sites in some way?
We get this same error too - we're not using multi-site.
We're getting this in multisites too
Just happened randomly on a "normal" singlesite
FYI folks you can stop this from appearing in your logs by add this to your app/Exceptions/Handler.php
:
In my case it was a visible error code, not just in the logs...
In my case it was a visible error code, not just in the logs...
This happened for me and my team as well, but only if the environment is NOT in production. When the environment is in production, everything is logged but the visitors don't get the error page.
It feels a bit like the error is thrown somewhere in the internals but doesn't actually stop execution.
Just to update on this. One of my traffic-heavy sites is experiencing CPU overloads and server crashes, and those seem to be happening at the exact same time that these errors appear in the logs.
It might be possible that this error causes a spike in CPU usage, or maybe this error is the result of an overstressed CPU. I wonder if anyone else is seeing this kind of behaviour...
I have added some additional details above after performing some investigation.
I was able to come up with a couple of workarounds for this issue because of the way we use our templates.
Workaround 1: validation rules on asset fields.
Use the dimensions
validation rule for assets field and specifiy the exact dimensions that you require for the images. This works well for images that don't need resizing when the browser changes size, such as social share images.
This workaround means you can use $asset->url()
or $asset->absoluteUrl()
directly instead of depending on Glide.
Workaround 2: generate srcsets on (image) asset upload.
You need to build a couple of things to get this approach to work:
srcset
for your image and updates the asset.srcset
attribute to each asset that needs it.Then all you have to do is replace Glide with attribute calls on the asset. I'm using $asset->srcset
myself.
I can probably create some gists if people need it.
☝️ I used both workarounds to remove Glide from our frontend completely; the only place we're using Glide is when an asset is uploaded or saved.
Experiencing this too with the eloquent driver and Statamic::tag('glide:generate')
in Blade. This does not fail silently for me - throws a 500 in both Production and Local environments.
@foreach(Statamic::tag('glide:generate')->src($post->assetObject)->fit('crop_focal') as $image)
<img src="{{ $image['url'] }}" alt="{{ $image['alt'] ?? '' }}" class="object-cover h-full w-full rounded ">
@endforeach
Laravel Version: 10.13.1 PHP Version: 8.2.6 Statamic Version: 3.5.0 PRO Environment: local
Same here. It's especially noticeable when running the static:warm
command in production. That produces random errors 500 with UnableToDeleteFile and UnableToSetVisibility showing up in monitoring.
PHP 8.1 Statamic 4.11.0 Laravel 10.15.0 Multi-site Assets cache = false
Also having this, on a single (non-multi) site, can't narrow it down to a schedule, seems to happen sporadically a few times a week;
[2023-08-24 20:56:22] production.ERROR: Unable to set visibility for file containers/assets/social-share-images/Social sharing - 1200 x 628.jpg/2e6867acc9a37569fcab8b1d0f53cd14.jpg. {"exception":"[object] (League\\Flysystem\\UnableToSetVisibility(code: 0): Unable to set visibility for file containers/assets/social-share-images/Social sharing - 1200 x 628.jpg/2e6867acc9a37569fcab8b1d0f53cd14.jpg. at /home/ploi/site.com.au/vendor/league/flysystem/src/UnableToSetVisibility.php:33)
[stacktrace]
#0 /home/ploi/site.com.au/vendor/league/flysystem-local/LocalFilesystemAdapter.php(460): League\\Flysystem\\UnableToSetVisibility::atLocation()
#1 /home/ploi/site.com.au/vendor/league/flysystem-local/LocalFilesystemAdapter.php(358): League\\Flysystem\\Local\\LocalFilesystemAdapter->setPermissions()
#2 /home/ploi/site.com.au/vendor/league/flysystem-local/LocalFilesystemAdapter.php(128): League\\Flysystem\\Local\\LocalFilesystemAdapter->setVisibility()
#3 /home/ploi/site.com.au/vendor/league/flysystem-local/LocalFilesystemAdapter.php(107): League\\Flysystem\\Local\\LocalFilesystemAdapter->writeToFile()
This is happening to me (500 using an external storage vendor like in #7193) and can't figure out how to fix it. It only started after doing a glide:clear
. I've regenerated assets, cleared all cache from everything. Anyone know how to get it working again
Bug description
I'm noticing random but frequent errors appearing in my server logs. They seem to happen randomly. I don't think they are affecting the visitor experience.
Example 1 - From asset field
Unable to set visibility for file containers/images/4.jpg/7a74d6248bee8f56088387bf4e26032e.webp
$image = Statamic::tag('glide:generate')->src($image)->params(['width' => 300, 'height' => 300, 'fm' => 'webp', 'fit' => 'crop_focal'])[0];
Example 2 - From local path
Unable to set visibility for file paths/images/table-no-space-middle1.jpg/989e5c2d05020abc66c4d34890951412.jpg
@foreach (Statamic::tag('glide:generate')->src('/images/table-no-space-middle1.jpg')->width(1200)->height(627)->fit('crop_focal')->fm('jpg') as $image)
How to reproduce
Not sure. Happens randomly.
glide:generate
tag. I am also using Spatie's responsive images but no errors seem to be emanating from there.Logs
Environment
Installation
Fresh statamic/statamic site via CLI
Antlers Parser
None
Additional details: file references
I logged into the server to investigate the troublesome file: /storage/statamic/glide/containers/images/4.jpg/7a74d6248bee8f56088387bf4e26032e.webp
I ran a search for references to this file in /storage/framework/cache/glide:
grep -ri "7a74d6248bee8f56088387bf4e26032e" /home/forge/www.mywebsite.com/storage/framework/cache/glide
This found two references in folders /glide/7f/06/ and /glide/65/ff/. Is this normal? Should there be two references to the same file?