Firestore insert or update problem when using laravel-octane
helomair opened this issue · comments
Describe the bug
When using laravel-octane (php artisan octane:start
), inserting or updating data to firestore will be blocked until request timeout.
But use normal (php artisan serve
) is fine
Installed packages
{
"name": "laravel/laravel",
"type": "project",
"description": "The skeleton application for the Laravel framework.",
"keywords": ["laravel", "framework"],
"license": "MIT",
"require": {
"php": "^8.1",
"google/cloud-firestore": "^1.39",
"guzzlehttp/guzzle": "^7.2",
"kreait/laravel-firebase": "^5.5",
"laravel/framework": "^10.10",
"laravel/octane": "^2.1",
"laravel/sanctum": "^3.3",
"laravel/tinker": "^2.8"
},
"require-dev": {
"fakerphp/faker": "^1.9.1",
"laravel/pint": "^1.0",
"laravel/sail": "^1.18",
"mockery/mockery": "^1.4.4",
"nunomaduro/collision": "^7.0",
"phpunit/phpunit": "^10.1",
"spatie/laravel-ignition": "^2.0"
},
"autoload": {
"psr-4": {
"App\\": "app/",
"Database\\Factories\\": "database/factories/",
"Database\\Seeders\\": "database/seeders/"
}
},
"autoload-dev": {
"psr-4": {
"Tests\\": "tests/"
}
},
"scripts": {
"post-autoload-dump": [
"Illuminate\\Foundation\\ComposerScripts::postAutoloadDump",
"@php artisan package:discover --ansi"
],
"post-update-cmd": [
"@php artisan vendor:publish --tag=laravel-assets --ansi --force"
],
"post-root-package-install": [
"@php -r \"file_exists('.env') || copy('.env.example', '.env');\""
],
"post-create-project-cmd": [
"@php artisan key:generate --ansi"
]
},
"extra": {
"laravel": {
"dont-discover": []
}
},
"config": {
"optimize-autoloader": true,
"preferred-install": "dist",
"sort-packages": true,
"allow-plugins": {
"pestphp/pest-plugin": true,
"php-http/discovery": true
}
},
"minimum-stability": "stable",
"prefer-stable": true
}
PHP version and extensions
composer 2.6.5 Composer package
composer-plugin-api 2.6.0 The Composer Plugin API
composer-runtime-api 2.2.2 The Composer Runtime API
ext-bcmath 8.1.26 The bcmath PHP extension
ext-calendar 8.1.26 The calendar PHP extension
ext-ctype 8.1.26 The ctype PHP extension
ext-curl 8.1.26 The curl PHP extension
ext-date 8.1.26 The date PHP extension
ext-dom 20031129 The dom PHP extension
ext-exif 8.1.26 The exif PHP extension
ext-ffi 8.1.26 The FFI PHP extension
ext-fileinfo 8.1.26 The fileinfo PHP extension
ext-filter 8.1.26 The filter PHP extension
ext-ftp 8.1.26 The ftp PHP extension
ext-gettext 8.1.26 The gettext PHP extension
ext-grpc 1.59.1 The grpc PHP extension
ext-hash 8.1.26 The hash PHP extension
ext-iconv 8.1.26 The iconv PHP extension
ext-intl 8.1.26 The intl PHP extension
ext-json 8.1.26 The json PHP extension
ext-libxml 8.1.26 The libxml PHP extension
ext-mbstring 8.1.26 The mbstring PHP extension
ext-mysqli 8.1.26 The mysqli PHP extension
ext-mysqlnd 0 The mysqlnd PHP extension (actual version: mysqlnd 8.1.26)
ext-openssl 8.1.26 The openssl PHP extension
ext-pcntl 8.1.26 The pcntl PHP extension
ext-pcre 8.1.26 The pcre PHP extension
ext-pdo 8.1.26 The PDO PHP extension
ext-pdo_mysql 8.1.26 The pdo_mysql PHP extension
ext-phar 8.1.26 The Phar PHP extension
ext-posix 8.1.26 The posix PHP extension
ext-readline 8.1.26 The readline PHP extension
ext-reflection 8.1.26 The Reflection PHP extension
ext-session 8.1.26 The session PHP extension
ext-shmop 8.1.26 The shmop PHP extension
ext-simplexml 8.1.26 The SimpleXML PHP extension
ext-soap 8.1.26 The soap PHP extension
ext-sockets 8.1.26 The sockets PHP extension
ext-sodium 8.1.26 The sodium PHP extension
ext-spl 8.1.26 The SPL PHP extension
ext-swoole 5.1.1 The swoole PHP extension
ext-sysvmsg 8.1.26 The sysvmsg PHP extension
ext-sysvsem 8.1.26 The sysvsem PHP extension
ext-sysvshm 8.1.26 The sysvshm PHP extension
ext-tokenizer 8.1.26 The tokenizer PHP extension
ext-xml 8.1.26 The xml PHP extension
ext-xmlreader 8.1.26 The xmlreader PHP extension
ext-xmlwriter 8.1.26 The xmlwriter PHP extension
ext-xsl 8.1.26 The xsl PHP extension
ext-zend-opcache 8.1.26 The Zend OPcache PHP extension
ext-zip 1.19.5 The zip PHP extension
ext-zlib 8.1.26 The zlib PHP extension
lib-curl 7.81.0 The curl library
lib-curl-libssh 0.9.6 curl libssh version
lib-curl-openssl 3.0.2 curl OpenSSL version (3.0.2)
lib-curl-zlib 1.2.11 curl zlib version
lib-date-timelib 2021.19 date timelib version
lib-date-zoneinfo 0 zoneinfo ("Olson") database for date
lib-fileinfo-libmagic 540 fileinfo libmagic version
lib-iconv 2.35 The iconv library
lib-icu 70.1 The ICU unicode and globalization support library
lib-icu-cldr 40 ICU CLDR project version
lib-icu-unicode 14.0.0 ICU unicode version
lib-icu-zoneinfo 2023.3 zoneinfo ("Olson") database for icu
lib-libsodium 1.0.18 The libsodium library
lib-libxml 2.9.14 libxml library version
lib-libxslt 1.1.34 The libxslt library
lib-libxslt-libxml 2.9.13 libxml version libxslt is compiled against
lib-mbstring-libmbfl 1.3.2 mbstring libmbfl version
lib-mbstring-oniguruma 6.9.7 mbstring oniguruma version
lib-openssl 3.0.2 OpenSSL 3.0.2 15 Mar 2022
lib-pcre 10.39 The pcre library
lib-pcre-unicode 14.0.0 PCRE Unicode version support
lib-zip-libzip 1.7.3 The zip-libzip library
lib-zlib 1.2.11 The zlib library
php 8.1.26 The PHP interpreter
php-64bit 8.1.26 The PHP interpreter, 64bit
php-ipv6 8.1.26 The PHP interpreter, with IPv6 support
Steps to reproduce the issue.
composer require -W google/cloud-firestore
# Normal
php artisan serve
# Laravel-Octane
php artisan octane:start
# Service
use Kreait\Laravel\Firebase\Facades\Firebase;
class FirebaseService {
protected $database;
public function __construct() {
$this->database = Firebase::firestore()->database();
}
public function firestoreUpdate(string $collection, array $data) {
$documentRef = $this->database->collection($collection)->document($data['id']);
$documentRef->set($data);
}
}
# Controller
use App\Services\FirebaseService;
class FireStoreController extends Controller
{
public function __construct(
protected FirebaseService $firebaseService
){}
public function store() {
$data = [
"id" => 'AAAA',
"message" => "Hello, world!!!"
];
$this->firebaseService->firestoreUpdate('test', $data);
return response()->json(['success' => true]);
}
}
Error message/Stack trace
-
Additional information
I've successfully reproduce the problem in single project:
https://github.com/helomair/laravel-octane-firebase-test
Thanks
The SDK only provides a bridge to the official google/cloud-firestore
library, so I'm afraid there is not much support I can provide, and I have never worked with Octane before.
As much as I would like to help, I think your question would be better placed in Google's repository.
@jeromegamez I think I found the answer, just set GRPC_ENABLE_FORK_SUPPORT=1
to environment, sorry for bothering and thank you for being patient with me.
No worries, I'm glad you found a solution, and thankful you shared it here, this will certainly be helpful to others! 🙏🏻