nystudio107 / craft-imageoptimize

Automatically create & optimize responsive image transforms, using either native Craft transforms or a service like Imgix, with zero template changes.
https://nystudio107.com/plugins/imageoptimize
Other
235 stars 36 forks source link

Image optimizations fail after saving #152

Closed cookie10codes closed 5 years ago

cookie10codes commented 5 years ago

Hi,

We're using image optimizations for the first time in a project. We have started to notice problems when the client updates entries or uploads images for optimizations and they fail. This results in many broken images on the website and we have to manual click "Try again" when opening the "Failed" in admin panel. We use Cloudfront AWS for handling our images.

We looked up the logs in craft storage, but nothing can be found... Are there any suggestions to solve this problem?

Kind regards, Stefanie

khalwat commented 5 years ago

@KoeketieneDesign Can you look at your storage/logs/queue.log to see if you find anything of note in there? Search on: [error]

cookie10codes commented 5 years ago

@khalwat I've attatched the log from queue (changed the amazon url to "PROJECT", it's the correct url.

Next Aws\S3\Exception\S3Exception: Error executing "ListObjects" on "https://PROJECT-production.s3.eu-central-1.amazonaws.com/?prefix=project_media%2Fh%C3%B4pital-g%C3%A9n%C3%A9ral-klina-oncologie%2F_576x324_crop_center-center_82_line%2Fhospitals-brasschaat-klina-oncology-4-web.jpg%2F&max-keys=1&encoding-type=url"; AWS HTTP error: Client error:GET https://PROJECT-production.s3.eu-central-1.amazonaws.com/?prefix=project_media%2Fh%C3%B4pital-g%C3%A9n%C3%A9ral-klina-oncologie%2F_576x324_crop_center-center_82_line%2Fhospitals-brasschaat-klina-oncology-4-web.jpg%2F&max-keys=1&encoding-type=urlresulted in a400 Bad Request` response: <?xml version="1.0" encoding="UTF-8"?>

ExpiredTokenThe provided token has expired. ExpiredTokenThe provided token has expired.FQoGZXIvYXdzENL//////////wEaDFzXNSQFyKCZs9PVKyKrAQ8VWAnkO82zYsRgPR2J5FSeLnLLH5HSTfPkyDT/8rCvaTvsSZyVm3xmWGlNHJeBdt6Mpui3BVe41Cjo7TC9/++CiqB9+UYhD8W6xxtvdETBjx5s4IazcUyHUN/rudc9sdSuzWbJX80aRbGU0wZF5GIE6jkwnclEzqDDgydbPmt2I+P12VNoDTeYOdoJ7ViYv8gQmpVzNeV4bN6NiYtRcQ/2d21oqnlDVHgstyirnLbpBQ==54E980B493EC445FTukB6mk+SL1/3UkTUR8Lwrh32VGP5FjqPcbBi9/ZbHUQv+M1VaZuoLJwtFcMT2tm51PeYoSdgPQ= in /var/web/releases/20190712064815/vendor/aws/aws-sdk-php/src/WrappedHttpHandler.php:191 Stack trace: #0 /var/web/releases/20190712064815/vendor/aws/aws-sdk-php/src/WrappedHttpHandler.php(97): Aws\WrappedHttpHandler->parseError(Array, Object(GuzzleHttp\Psr7\Request), Object(Aws\Command), Array) #1 /var/web/releases/20190712064815/vendor/guzzlehttp/promises/src/Promise.php(203): Aws\WrappedHttpHandler->Aws\{closure}(Array) #2 /var/web/releases/20190712064815/vendor/guzzlehttp/promises/src/Promise.php(174): GuzzleHttp\Promise\Promise::callHandler(2, Array, Array) #3 /var/web/releases/20190712064815/vendor/guzzlehttp/promises/src/RejectedPromise.php(40): GuzzleHttp\Promise\Promise::GuzzleHttp\Promise\{closure}(Array) #4 /var/web/releases/20190712064815/vendor/guzzlehttp/promises/src/TaskQueue.php(47): GuzzleHttp\Promise\RejectedPromise::GuzzleHttp\Promise\{closure}() #5 /var/web/releases/20190712064815/vendor/guzzlehttp/guzzle/src/Handler/CurlMultiHandler.php(98): GuzzleHttp\Promise\TaskQueue->run() #6 /var/web/releases/20190712064815/vendor/guzzlehttp/guzzle/src/Handler/CurlMultiHandler.php(125): GuzzleHttp\Handler\CurlMultiHandler->tick() #7 /var/web/releases/20190712064815/vendor/guzzlehttp/promises/src/Promise.php(246): GuzzleHttp\Handler\CurlMultiHandler->execute(true) #8 /var/web/releases/20190712064815/vendor/guzzlehttp/promises/src/Promise.php(223): GuzzleHttp\Promise\Promise->invokeWaitFn() #9 /var/web/releases/20190712064815/vendor/guzzlehttp/promises/src/Promise.php(267): GuzzleHttp\Promise\Promise->waitIfPending() #10 /var/web/releases/20190712064815/vendor/guzzlehttp/promises/src/Promise.php(225): GuzzleHttp\Promise\Promise->invokeWaitList() #11 /var/web/releases/20190712064815/vendor/guzzlehttp/promises/src/Promise.php(267): GuzzleHttp\Promise\Promise->waitIfPending() #12 /var/web/releases/20190712064815/vendor/guzzlehttp/promises/src/Promise.php(225): GuzzleHttp\Promise\Promise->invokeWaitList() #13 /var/web/releases/20190712064815/vendor/guzzlehttp/promises/src/Promise.php(62): GuzzleHttp\Promise\Promise->waitIfPending() #14 /var/web/releases/20190712064815/vendor/aws/aws-sdk-php/src/AwsClientTrait.php(58): GuzzleHttp\Promise\Promise->wait() #15 /var/web/releases/20190712064815/vendor/league/flysystem-aws-s3-v3/src/AwsS3Adapter.php(689): Aws\AwsClient->execute(Object(Aws\Command)) #16 /var/web/releases/20190712064815/vendor/league/flysystem-aws-s3-v3/src/AwsS3Adapter.php(238): League\Flysystem\AwsS3v3\AwsS3Adapter->doesDirectoryExist('project_media/h...') #17 /var/web/releases/20190712064815/vendor/league/flysystem/src/Filesystem.php(57): League\Flysystem\AwsS3v3\AwsS3Adapter->has('h\xC3\xB4pital-g\xC3\xA9n\xC3\xA9...') #18 /var/web/releases/20190712064815/vendor/craftcms/cms/src/base/FlysystemVolume.php(109): League\Flysystem\Filesystem->has('h\xC3\xB4pital-g\xC3\xA9n\xC3\xA9...') #19 /var/web/releases/20190712064815/vendor/craftcms/cms/src/services/AssetTransforms.php(1388): craft\base\FlysystemVolume->fileExists('h\xC3\xB4pital-g\xC3\xA9n\xC3\xA9...') #20 /var/web/releases/20190712064815/vendor/craftcms/cms/src/services/AssetTransforms.php(701): craft\services\AssetTransforms->_createTransformForAsset(Object(craft\elements\Asset), Object(craft\models\AssetTransformIndex)) #21 /var/web/releases/20190712064815/vendor/craftcms/cms/src/services/AssetTransforms.php(604): craft\services\AssetTransforms->_generateTransform(Object(craft\models\AssetTransformIndex)) #22 /var/web/releases/20190712064815/vendor/craftcms/cms/src/services/Assets.php(599): craft\services\AssetTransforms->ensureTransformUrlByIndexModel(Object(craft\models\AssetTransformIndex)) #23 /var/web/releases/20190712064815/vendor/nystudio107/craft-imageoptimize/src/imagetransforms/CraftImageTransform.php(55): craft\services\Assets->getAssetUrl(Object(craft\elements\Asset), Object(craft\models\AssetTransform), true) #24 /var/web/releases/20190712064815/vendor/nystudio107/craft-imageoptimize/src/services/OptimizedImages.php(417): nystudio107\imageoptimize\imagetransforms\CraftImageTransform->getTransformUrl(Object(craft\elements\Asset), Object(craft\models\AssetTransform), Array) #25 /var/web/releases/20190712064815/vendor/nystudio107/craft-imageoptimize/src/services/OptimizedImages.php(102): nystudio107\imageoptimize\services\OptimizedImages->addVariantImageToModel(Object(craft\elements\Asset), Object(nystudio107\imageoptimize\models\OptimizedImage), Object(craft\models\AssetTransform), Array, 1.7777777777778) #26 /var/web/releases/20190712064815/vendor/nystudio107/craft-imageoptimize/src/services/OptimizedImages.php(177): nystudio107\imageoptimize\services\OptimizedImages->populateOptimizedImageModel(Object(craft\elements\Asset), Array, Object(nystudio107\imageoptimize\models\OptimizedImage)) #27 /var/web/releases/20190712064815/vendor/nystudio107/craft-imageoptimize/src/jobs/ResaveOptimizedImages.php(86): nystudio107\imageoptimize\services\OptimizedImages->updateOptimizedImageFieldData(Object(nystudio107\imageoptimize\fields\OptimizedImages), Object(craft\elements\Asset)) #28 /var/web/releases/20190712064815/vendor/yiisoft/yii2-queue/src/Queue.php(214): nystudio107\imageoptimize\jobs\ResaveOptimizedImages->execute(Object(craft\queue\Queue)) #29 /var/web/releases/20190712064815/vendor/yiisoft/yii2-queue/src/cli/Queue.php(147): yii\queue\Queue->handleMessage('23118', 'O:52:"nystudio1...', '300', 1) #30 /var/web/releases/20190712064815/vendor/craftcms/cms/src/queue/Queue.php(96): yii\queue\cli\Queue->handleMessage('23118', 'O:52:"nystudio1...', '300', 1) #31 /var/web/releases/20190712064815/vendor/craftcms/cms/src/controllers/QueueController.php(86): craft\queue\Queue->run() #32 [internal function]: craft\controllers\QueueController->actionRun() #33 /var/web/releases/20190712064815/vendor/yiisoft/yii2/base/InlineAction.php(57): call_user_func_array(Array, Array) #34 /var/web/releases/20190712064815/vendor/yiisoft/yii2/base/Controller.php(157): yii\base\InlineAction->runWithParams(Array) #35 /var/web/releases/20190712064815/vendor/craftcms/cms/src/web/Controller.php(109): yii\base\Controller->runAction('run', Array) #36 /var/web/releases/20190712064815/vendor/yiisoft/yii2/base/Module.php(528): craft\web\Controller->runAction('run', Array) #37 /var/web/releases/20190712064815/vendor/craftcms/cms/src/web/Application.php(297): yii\base\Module->runAction('queue/run', Array) #38 /var/web/releases/20190712064815/vendor/craftcms/cms/src/web/Application.php(565): craft\web\Application->runAction('queue/run', Array) #39 /var/web/releases/20190712064815/vendor/craftcms/cms/src/web/Application.php(281): craft\web\Application->_processActionRequest(Object(craft\web\Request)) #40 /var/web/releases/20190712064815/vendor/yiisoft/yii2/base/Application.php(386): craft\web\Application->handleRequest(Object(craft\web\Request)) #41 /var/web/releases/20190712064815/web/index.php(21): yii\base\Application->run() #42 {main}`
khalwat commented 5 years ago

This is an issue with the AWS S3 plugin from Pixel & Tonic that I fixed with a pull request: https://github.com/craftcms/aws-s3/pull/61

If you update to the latest AWS S3 plugin, this should be fixed. You'll want version 1.2.4 or later https://github.com/craftcms/aws-s3