Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug: TypeError: Kreait\Firebase\Messaging:100 #894

Closed
ibrunotome opened this issue May 20, 2024 · 2 comments · Fixed by #896
Closed

bug: TypeError: Kreait\Firebase\Messaging:100 #894

ibrunotome opened this issue May 20, 2024 · 2 comments · Fixed by #896
Assignees

Comments

@ibrunotome
Copy link

Describe the bug

I got this error for some minutes and them all start to working again, but I think it makes sense to inform you anyway:

TypeError: Kreait\Firebase\Messaging::Kreait\Firebase{closure}(): Argument #1 ($reason) must be of type GuzzleHttp\Exception\RequestException, GuzzleHttp\Exception\ConnectException given, called in /app/vendor/guzzlehttp/promises/src/EachPromise.php on line 183 and defined in /app/vendor/kreait/firebase-php/src/Firebase/Messaging.php:100

https://github.com/kreait/firebase-php/blob/7.x/src/Firebase/Messaging.php#L100

The reject callback received a ConnectException instead of a RequestException

Installed packages

"php": "^8.3",
    "ext-bcmath": "*",
    "ext-pdo": "*",
    "firebase/php-jwt": "^6.9",
    "guzzlehttp/guzzle": "^7.2",
    "hammerstone/sidecar": "^0.6.1",
    "jenssegers/agent": "^2.6",
    "laravel-notification-channels/fcm": "^4.3",
    "laravel/cashier": "^15.1",
    "laravel/framework": "^v11.0",
    "laravel/horizon": "^5.20",
    "laravel/nova": "^4.33",
    "laravel/octane": "^2.0",
    "laravel/sanctum": "^4.0",
    "laravel/telescope": "^5.0",
    "laravel/tinker": "^2.8",
    "league/flysystem-aws-s3-v3": "^3.0",
    "outl1ne/nova-settings": "^5.2",
    "owen-it/laravel-auditing": "^13.5",
    "sentry/sentry-laravel": "^4.3",
    "spatie/laravel-pdf": "^1.5",
    "spatie/laravel-sluggable": "^3.5",
    "spatie/laravel-webhook-client": "^3.3",
    "tpetry/laravel-postgresql-enhanced": "^0.38",
    "wnx/sidecar-browsershot": "^2.3.3"

PHP version and extensions

/app # php -v
PHP 8.3.6 (cli) (built: Apr 11 2024 18:32:01) (ZTS)
Copyright (c) The PHP Group
Zend Engine v4.3.6, Copyright (c) Zend Technologies
    with Zend OPcache v8.3.6, Copyright (c), by Zend Technologies
/app # php -m
[PHP Modules]
bcmath
Core
ctype
curl
date
dom
fileinfo
filter
hash
iconv
intl
json
libxml
mbstring
mysqlnd
openssl
pcntl
pcov
pcre
PDO
pdo_mysql
pdo_pgsql
pdo_sqlite
Phar
posix
random
readline
redis
Reflection
session
SimpleXML
sodium
SPL
sqlite3
standard
tokenizer
xml
xmlreader
xmlwriter
Zend OPcache
zlib

[Zend Modules]
Zend OPcache


### Steps to reproduce the issue.

The notification that was sent is a Queueable notification that implements the ShouldQueueAfterCommit interface:

```php
    public function toFcm(): FcmMessage
    {
        return (new FcmMessage(notification: new FcmNotification(
            title: 'Nova Proposta de Parceria',
            body: "Você recebeu uma nova proposta da marca {$this->data['company_name']}. Veja os detalhes agora.",
        )))
            ->data([
                'company_name'  => $this->data['company_name'],
                'influencer_id' => $this->data['influencer_id'],
            ])
            ->custom([
                'android' => [
                    'notification' => [
                        'color' => '#0A0A0A',
                    ],
                    'fcm_options' => [
                        'analytics_label' => 'analytics',
                    ],
                ],
                'apns' => [
                    'fcm_options' => [
                        'analytics_label' => 'analytics',
                    ],
                ],
            ]);
    }

Error message/Stack trace

TypeError: Kreait\Firebase\Messaging::Kreait\Firebase\{closure}(): Argument #1 ($reason) must be of type GuzzleHttp\Exception\RequestException, GuzzleHttp\Exception\ConnectException given, called in /app/vendor/guzzlehttp/promises/src/EachPromise.php on line 183 and defined in /app/vendor/kreait/firebase-php/src/Firebase/Messaging.php:100
Stack trace:
#0 /app/vendor/guzzlehttp/promises/src/EachPromise.php(183): Kreait\Firebase\Messaging->Kreait\Firebase\{closure}(Object(GuzzleHttp\Exception\ConnectException), 2, Object(GuzzleHttp\Promise\Promise))
#1 /app/vendor/guzzlehttp/promises/src/Promise.php(209): GuzzleHttp\Promise\EachPromise->GuzzleHttp\Promise\{closure}(Object(GuzzleHttp\Exception\ConnectException))
#2 /app/vendor/guzzlehttp/promises/src/Promise.php(158): GuzzleHttp\Promise\Promise::callHandler(2, Object(GuzzleHttp\Exception\ConnectException), NULL)
#3 /app/vendor/guzzlehttp/promises/src/TaskQueue.php(52): GuzzleHttp\Promise\Promise::GuzzleHttp\Promise\{closure}()
#4 /app/vendor/guzzlehttp/guzzle/src/Handler/CurlMultiHandler.php(163): GuzzleHttp\Promise\TaskQueue->run()
#5 /app/vendor/guzzlehttp/guzzle/src/Handler/CurlMultiHandler.php(189): GuzzleHttp\Handler\CurlMultiHandler->tick()
#6 /app/vendor/guzzlehttp/promises/src/Promise.php(251): GuzzleHttp\Handler\CurlMultiHandler->execute(true)
#7 /app/vendor/guzzlehttp/promises/src/Promise.php(227): GuzzleHttp\Promise\Promise->invokeWaitFn()
#8 /app/vendor/guzzlehttp/promises/src/Promise.php(272): GuzzleHttp\Promise\Promise->waitIfPending()
#9 /app/vendor/guzzlehttp/promises/src/Promise.php(229): GuzzleHttp\Promise\Promise->invokeWaitList()
#10 /app/vendor/guzzlehttp/promises/src/Promise.php(69): GuzzleHttp\Promise\Promise->waitIfPending()
#11 /app/vendor/guzzlehttp/promises/src/EachPromise.php(109): GuzzleHttp\Promise\Promise->wait()
#12 /app/vendor/guzzlehttp/promises/src/Promise.php(251): GuzzleHttp\Promise\EachPromise->GuzzleHttp\Promise\{closure}(true)
#13 /app/vendor/guzzlehttp/promises/src/Promise.php(227): GuzzleHttp\Promise\Promise->invokeWaitFn()
#14 /app/vendor/guzzlehttp/promises/src/Promise.php(69): GuzzleHttp\Promise\Promise->waitIfPending()
#15 /app/vendor/kreait/firebase-php/src/Firebase/Messaging.php(109): GuzzleHttp\Promise\Promise->wait()
#16 /app/vendor/kreait/firebase-php/src/Firebase/Messaging.php(83): Kreait\Firebase\Messaging->sendAll(Array, false)
#17 /app/vendor/laravel-notification-channels/fcm/src/FcmChannel.php(46): Kreait\Firebase\Messaging->sendMulticast(Object(Kreait\Firebase\Messaging\CloudMessage), Object(Kreait\Firebase\Messaging\RegistrationTokens))
#18 [internal function]: NotificationChannels\Fcm\FcmChannel->NotificationChannels\Fcm\{closure}(Object(Illuminate\Support\Collection), 0)
#19 /app/vendor/laravel/framework/src/Illuminate/Collections/Arr.php(605): array_map(Object(Closure), Array, Array)
#20 /app/vendor/laravel/framework/src/Illuminate/Collections/Collection.php(777): Illuminate\Support\Arr::map(Array, Object(Closure))
#21 /app/vendor/laravel-notification-channels/fcm/src/FcmChannel.php(46): Illuminate\Support\Collection->map(Object(Closure))


### Additional information

_No response_
@jeromegamez
Copy link
Member

Could you please confirm if #896 works as expected, and comment on the PR if yes or no? Thanks!

@FluffyDiscord
Copy link

Can you please do a small new release with this fix?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants