spatie / statamic-responsive-images

Responsive images for Statamic 3
MIT License
99 stars 29 forks source link

Unable to read file from location #195

Closed stuartcusackie closed 1 year ago

stuartcusackie commented 1 year ago

Bug description

Just had a random crash as a client was editing content.

Unable to read file from location: containers/images/clubs/aston-quay-44.jpg/35460d82eb5142426fb66450f2dc015c.jpg.

I FTPd to the server to check the cache folders at storage/statamic/glide/containers/etc and the file was missing. I guess there was a reference to this file somewhere in storage/framework/cache/glide but for some reason the file did not exist.

My image manipulation cache is set to false and the website has been running fine for a month. Seems totally random.

It seems similar to this issue: https://github.com/spatie/statamic-responsive-images/issues/171. I opened a core issue here: https://github.com/statamic/cms/issues/7350

How to reproduce

No idea.

Logs

{
    "class": "Spatie\\LaravelIgnition\\Exceptions\\ViewException",
    "message": "Unable to read file from location: containers/images/clubs/aston-quay-44.jpg/35460d82eb5142426fb66450f2dc015c.jpg.",
    "code": 0,
    "file": "/home/forge/mysite.ie/vendor/league/flysystem/src/UnableToReadFile.php:24",
    "trace": [
        "/home/forge/mysite.ie/vendor/league/flysystem/src/Local/LocalFilesystemAdapter.php:265",
        "/home/forge/mysite.ie/vendor/league/flysystem/src/Filesystem.php:75",
        "/home/forge/mysite.ie/vendor/laravel/framework/src/Illuminate/Filesystem/FilesystemAdapter.php:951",
        "/home/forge/mysite.ie/vendor/spatie/statamic-responsive-images/src/Breakpoint.php:269",
        "/home/forge/mysite.ie/vendor/spatie/blink/src/Blink.php:279",
        "/home/forge/mysite.ie/vendor/statamic/cms/src/Support/Blink.php:18",
        "/home/forge/mysite.ie/vendor/laravel/framework/src/Illuminate/Support/Facades/Facade.php:338",
        "/home/forge/mysite.ie/vendor/spatie/statamic-responsive-images/src/Breakpoint.php:278",
        "/home/forge/mysite.ie/vendor/spatie/statamic-responsive-images/src/Breakpoint.php:215",
        "/home/forge/mysite.ie/vendor/spatie/statamic-responsive-images/src/Breakpoint.php:246",
        "/home/forge/mysite.ie/vendor/spatie/statamic-responsive-images/src/Breakpoint.php:62",
        "/home/forge/mysite.ie/vendor/laravel/framework/src/Illuminate/Conditionable/Traits/Conditionable.php:34",
        "/home/forge/mysite.ie/vendor/spatie/statamic-responsive-images/src/Breakpoint.php:63",
        "/home/forge/mysite.ie/vendor/spatie/statamic-responsive-images/src/Tags/ResponsiveTag.php:75",
        "/home/forge/mysite.ie/vendor/laravel/framework/src/Illuminate/Collections/Arr.php:560",
        "/home/forge/mysite.ie/vendor/laravel/framework/src/Illuminate/Collections/Collection.php:739",

Environment

Environment
Laravel Version: 9.43.0
PHP Version: 8.1.12

Statamic
Version: 3.3.60 PRO

Statamic Addons
jonassiewertsen/statamic-live-search: 1.5.1
jonassiewertsen/statamic-livewire: 2.9.0
justbetter/statamic-image-optimize: 1.1.4
rias/statamic-redirect: 2.5.0
spatie/statamic-responsive-images: 2.14.4
statamic/seo-pro: 3.1.3
stuartcusackie/statamic-cache-requester: 1.0.2

Installation

Fresh statamic/statamic site via CLI

Antlers Parser

regex (default)

Additional details

No response

ncla commented 1 year ago

Yeah, it's same issue. Update to latest version and that error will be silenced for production. :man_shrugging: This is same behavior as glide:data_uri tag, the core just silences any errors coming when reading from image manipulation directory cache. https://github.com/statamic/cms/blob/3.3/src/Tags/Glide.php#L212-L227

If you want you can update the issue on core saying it can happen with glide:data_url too. I am not sure I agree on them silencing errors on the tag though, but it might be I don't know something, or it's too annoying to fix.

Sorry for the trouble!

stuartcusackie commented 1 year ago

Ah I see. I opened this because I thought it was addressed in v2.14.2, and I was running v2.14.4. Looks like 2.14.5 handled it. I will update. Thank you!

I will update my core issue.

ncla commented 1 year ago

v2.14.2 only fixed issue if you changed the cache settings for image_manipulations. In this I version removed try.. catch from placeholder generation unaware that it is there for a reason. Then it was readded back v2.14.5.

There is a bigger underlying issue that just needs to be fixed in the core. The "fix" I reapplied in 2.14.5 is simply hiding it under the rug. It has to be resolved in core.

(I started writing this reply to your first unedited message FYI :sweat_smile: )