-
Notifications
You must be signed in to change notification settings - Fork 381
Description
What happened?
Description
When running my Laravel application with FrankenPHP in worker mode, the container crashes and restarts every time I use spatie/async
to create an asynchronous pool. The issue seems to be that the main FrankenPHP worker process is being killed by an underlying process management mechanism, possibly related to Symfony Process.
The application works flawlessly in every other scenario, with significantly improved performance in worker mode. The crash only occurs specifically when Spatie\Async\Pool
is used.
Steps to Reproduce
-
Set up a Laravel 12 application with FrankenPHP in worker mode.
-
Install
spatie/async
via Composer. -
Create a simple route or command that uses
Spatie\Async\Pool
to execute a task, for example:use Spatie\Async\Pool; Route::get('/async-test', function () { $pool = Pool::create(); $pool->add(function () { // Your async task here sleep(2); return 'Task finished'; })->then(function ($output) { echo $output; }); $pool->wait(); });
-
Access the route.
Expected Behavior
The asynchronous task should be executed by spatie/async
without causing the main FrankenPHP worker process to crash. The application should return the response normally.
Actual Behavior
The Spatie\Async\Pool
function seems to trigger a process shutdown. The container crashes immediately after the async pool is created, and it is then automatically restarted by Docker.
Environment
- FrankenPHP Version: dunglas/frankenphp:1-php8.3-alpine
- Laravel Version: 12
- PHP Version: 8.3
- Spatie/Async Version: 1.6
- Operating System: macOS (Apple M2 chip)
- Docker: 4.43.2
Possible Cause
The spatie/async
package uses pcntl_fork()
to create new processes. It is likely that this behavior is incompatible with the long-running worker processes of FrankenPHP. The main worker process might be interpreting the spawned child process as an unexpected termination of a subprocess, leading to its own shutdown to prevent a corrupted state.
This seems to be a common issue with pcntl_fork()
and long-running PHP application servers like Swoole and FrankenPHP.
Build Type
Docker (Alpine)
Worker Mode
Yes
Operating System
macOS
CPU Architecture
Apple Silicon
PHP configuration
'./configure' '--prefix=' '--with-valgrind=no' '--disable-shared' '--enable-static' '--disable-all' '--disable-cgi' '--disable-phpdbg' '--with-pic' '--disable-cli' '--disable-fpm' '--enable-embed=static' '--disable-micro' '--with-config-file-path=/etc/frankenphp' '--with-config-file-scan-dir=/etc/frankenphp/php.d' '--disable-opcache-jit' '--enable-zts' '--disable-zend-signals' '--enable-zend-max-execution-timers' '--with-amqp' '--with-librabbitmq-dir=/go/src/app/dist/static-php-cli/buildroot' '--enable-apcu' '--enable-ast' '--enable-bcmath' '--enable-brotli' '--with-bz2=/go/src/app/dist/static-php-cli/buildroot' '--enable-calendar' '--enable-ctype' '--with-curl' '--enable-dba' '--enable-dom' '--enable-exif' '--enable-fileinfo' '--enable-filter' '--enable-ftp' '--with-zlib' '--enable-gd' '--with-freetype' '--with-jpeg' '--with-webp' '--with-avif' '--with-gmp=/go/src/app/dist/static-php-cli/buildroot' '--with-gettext=/go/src/app/dist/static-php-cli/buildroot' '--with-iconv=/go/src/app/dist/static-php-cli/buildroot' '--enable-session' '--enable-igbinary' '--with-imagick=/go/src/app/dist/static-php-cli/buildroot' 'ac_cv_func_omp_pause_resource_all=no' '--enable-intl' '--with-ldap=/go/src/app/dist/static-php-cli/buildroot' '--enable-lz4' '--with-lz4-includedir=/go/src/app/dist/static-php-cli/buildroot' '--enable-mbstring' '--enable-mbregex' '--enable-mysqlnd' '--with-mysqli' '--enable-opcache' '--with-password-argon2' '--enable-parallel' '--enable-pcntl' '--enable-pdo' '--with-pdo-mysql' '--with-pgsql' 'PGSQL_CFLAGS=-I/go/src/app/dist/static-php-cli/buildroot/include' 'PGSQL_LIBS=-L/go/src/app/dist/static-php-cli/buildroot/lib -lpq -lpgcommon -lpgport -lzstd -lldap -llber -lsodium -lgmp -lreadline -lncurses -lssl -lcrypto -lxml2 -lz -licuio -licui18n -licuuc -licudata -lpthread -lm -llzma -liconv -lcharset -ldl -lpthread -lm -lstdc++ -liconv -lcharset -ldl -lpthread -lm -lstdc++ -llzma -liconv -lcharset -ldl -lpthread -lm -lstdc++ -licuio -licui18n -licuuc -licudata -lpthread -lm -ldl -lpthread -lm -lstdc++ -lz -ldl -lpthread -lm -lstdc++ -lxml2 -lz -licuio -licui18n -licuuc -licudata -lpthread -lm -llzma -liconv -lcharset -ldl -lpthread -lm -lstdc++ -lssl -lcrypto -lz -ldl -lpthread -lm -lstdc++ -lncurses -ldl -lpthread -lm -lstdc++ -lreadline -lncurses -ldl -lpthread -lm -lstdc++ -lgmp -ldl -lpthread -lm -lstdc++ -lsodium -ldl -lpthread -lm -lstdc++ -lldap -llber -lsodium -lgmp -lssl -lcrypto -lz -ldl -lpthread -lm -lstdc++ -lzstd -ldl -lpthread -lm -lstdc++' '--with-pdo-pgsql=/go/src/app/dist/static-php-cli/buildroot' '--with-sqlite3=/go/src/app/dist/static-php-cli/buildroot' '--with-pdo-sqlite' '--enable-sqlsrv' '--with-pdo-sqlsrv' '--enable-phar' '--enable-posix' '--enable-protobuf' '--without-libedit' '--with-readline=/go/src/app/dist/static-php-cli/buildroot' 'ac_cv_lib_readline_rl_pending_input=yes' '--enable-redis' '--enable-redis-session' '--enable-redis-igbinary' '--enable-redis-zstd' '--enable-redis-lz4' '--with-liblz4=/go/src/app/dist/static-php-cli/buildroot' '--enable-shmop' '--enable-simplexml' '--enable-soap' '--enable-sockets' '--with-sodium' '--with-ssh2=/go/src/app/dist/static-php-cli/buildroot' '--enable-sysvmsg' '--enable-sysvsem' '--enable-sysvshm' '--with-tidy=/go/src/app/dist/static-php-cli/buildroot' '--enable-tokenizer' '--with-zip=/go/src/app/dist/static-php-cli/buildroot' '--with-xlswriter' '--enable-reader' '--with-openssl=/go/src/app/dist/static-php-cli/buildroot' '--enable-xml' '--enable-xmlreader' '--enable-xmlwriter' '--with-libxml=/go/src/app/dist/static-php-cli/buildroot' '--with-xz' '--with-yaml=/go/src/app/dist/static-php-cli/buildroot' '--enable-zstd' '--with-libzstd=/go/src/app/dist/static-php-cli/buildroot' 'PKG_CONFIG=/go/src/app/dist/static-php-cli/buildroot/bin/pkg-config' 'PKG_CONFIG_PATH=/go/src/app/dist/static-php-cli/buildroot/lib/pkgconfig' 'EXTENSION_DIR=/usr/lib/frankenphp/modules' 'PHP_BUILD_PROVIDER=static-php-cli 2.7.2' 'PHP_BUILD_COMPILER=gcc 4.2.0'