guzzle / promises

Promises/A+ library for PHP with synchronous support
MIT License
7.61k stars 116 forks source link

undefined method named "of" of class "GuzzleHttp\Promise\Coroutine" #130

Closed keulinho closed 4 years ago

keulinho commented 4 years ago

PHP version: 7.4.10

Description After updating to guzzle 1.4.0 there occurs an error that the mehtod Coroutine::of() method cannot be found.

Attempted to call an undefined method named "of" of class "GuzzleHttp\Promise\Coroutine".

How to reproduce Seems like an issue when using the coroutine() function. See stacktrace below.

Additional context This issue occured in combination with using flysystem & the aws s3 adapter of flysystem. The error occured when Filesystem::deleteDir() was called.

Full stacktrace:

Exception trace:
  at /var/www/html/vendor/guzzlehttp/promises/src/functions.php:362
 GuzzleHttp\Promise\coroutine() at /var/www/html/vendor/aws/aws-sdk-php/src/S3/BatchDelete.php:109
 Aws\S3\BatchDelete::Aws\S3\{closure}() at n/a:n/a
 call_user_func() at /var/www/html/vendor/aws/aws-sdk-php/src/S3/BatchDelete.php:217
 Aws\S3\BatchDelete->createPromise() at /var/www/html/vendor/aws/aws-sdk-php/src/S3/BatchDelete.php:118
 Aws\S3\BatchDelete->promise() at /var/www/html/vendor/aws/aws-sdk-php/src/S3/S3ClientTrait.php:139
 Aws\S3\S3Client->deleteMatchingObjectsAsync() at /var/www/html/vendor/aws/aws-sdk-php/src/S3/S3ClientTrait.php:110
 Aws\S3\S3Client->deleteMatchingObjects() at /var/www/html/vendor/league/flysystem-aws-s3-v3/src/AwsS3Adapter.php:202
 League\Flysystem\AwsS3v3\AwsS3Adapter->deleteDir() at /var/www/html/vendor/league/flysystem/src/Filesystem.php:251
 League\Flysystem\Filesystem->deleteDir() at /var/www/html/vendor/shopware/storefront/Theme/ThemeCompiler.php:110
GrahamCampbell commented 4 years ago

Looks like you need to restart php-fpm because you have a stale cache of the Coroutine.php file. Either that, or you need to delete you vendor folder and composer cache, and run composer update.

keulinho commented 4 years ago

We have immutable infrastructure and build the whole container anew for each update, including the composer dependencies. Meaning restarting php-fpm or running composer update should not have any affect as we do a clean composer install each time.

The logs from composer update clearly state that it installed v1.4.0:

  - Downloading guzzlehttp/psr7 (1.7.0)
  - Downloading guzzlehttp/promises (1.4.0)
  - Downloading guzzlehttp/guzzle (6.5.2)

The thing that confuses me most is that functions.php has to be up2date as it tries to make the "new" call to the Coroutine::of() method, but the loaded Coroutine class, that should be loaded from the same folder/namespace seems to be an old version that does not have the of() method. :thinking:

GrahamCampbell commented 4 years ago

That indicates there is not a bug here, just that your vendor folder didn't get updated properly. Delete you composer cache directory as well as the vendor folder. The 1.4.0 zip definitely has the correct files in it: https://github.com/guzzle/promises/archive/1.4.0.zip.

keulinho commented 4 years ago

After quite some debugging we found the source for this problems. The Coroutine class was autoloaded from another vendor folder than the functions file.

But thank you for your fast replies & your support.