v1.13.0: config reload returns HTTP 500 "server is not registered, you must first call frankenphp.Init() with the WithServer() option" while workers boot (regression from v1.12.7)
Les mainteneurs répondent en général sous 1 jour
Personne n'a encore pris cette issue.
- #2705 par @dunglas — fermée sans fusion
Évaluation
- Difficulté
- 4/5
- Temps estimé
- 3-5 jours
- Accessibilité débutants
- 54/100
Piste de recherche
Start with server.go around ServeHTTP and caddy/module.go around lines 229–232, where the issue traces ErrNotRunning into HTTP 500 responses. Compare the reload lifecycle with the linked discussions in #2648, #2645, and #2469. Reproduce using the provided worker script and Caddyfile with BOOT_DELAY_MS=300, then verify repeated config reloads no longer cause 500 responses.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Description
What happened?
Since v1.13.0, every config reload in worker mode makes FrankenPHP answer requests with an HTTP 500 and an empty body for as long as the new workers take to boot. The error log shows server is not registered, you must first call frankenphp.Init() with the WithServer() option (ErrNotRunning), raised at caddy.(*FrankenPHPModule).ServeHTTP (module.go:231). On v1.12.7, the same setup and load produce no 500s.
We found this with Laravel Octane: php artisan octane:reload does a GET /config/apps/frankenphp on the admin API and PATCHes the same body back with Cache-Control: must-revalidate. The bug also reproduces without Laravel and Octane, using a minimal worker script with a simulated bootstrap delay (see below).
Minimal reproduction
public/worker.php:
<?php
// BOOT_DELAY_MS simulates a framework bootstrap (Laravel takes ~300 ms here).
usleep((int) (getenv('BOOT_DELAY_MS') ?: 0) * 1000);
ignore_user_abort(true);
$handler = static function (): void {
echo 'ok';
};
while (frankenphp_handle_request($handler)) {
gc_collect_cycles();
}
Caddyfile:
{
admin 127.0.0.1:{$ADMIN_PORT}
auto_https disable_redirects
frankenphp {
worker {
file /path/to/public/worker.php
num 2
}
}
}
http://:{$PORT} {
bind 127.0.0.1
route {
root * /path/to/public
php_server {
index worker.php
try_files {path} worker.php
}
}
}
reload.sh (what Laravel Octane's octane:reload sends):
#!/bin/sh
ADMIN=${ADMIN:-http://127.0.0.1:8097}
curl -s "$ADMIN/config/apps/frankenphp" -o /tmp/fp-cfg.json
curl -s -X PATCH -H 'Content-Type: application/json' -H 'Cache-Control: must-revalidate' \
--data-binary @/tmp/fp-cfg.json "$ADMIN/config/apps/frankenphp"
Steps:
PORT=3097 ADMIN_PORT=8097 BOOT_DELAY_MS=300 frankenphp run --config Caddyfile- Generate about 20 req/s against
http://127.0.0.1:3097/(we used batches of 4 parallelcurl -m 10every 200 ms). - Run
reload.sha few times, 10 s apart. - Count the non-200 responses.
Results (3 reloads per round, ~800–900 requests per round; v1.12.7 and v1.13.0 side by side on the same host):
| Setup | v1.12.7 | v1.13.0 |
|---|---|---|
Minimal worker, BOOT_DELAY_MS=0 (2 rounds) |
0 / 0 errors | 0 / 0 errors |
Minimal worker, BOOT_DELAY_MS=300 (2 rounds) |
0 / 0 errors | 15 / 20 × HTTP 500 |
Laravel 12.61.1 + Octane 2.17.4, 2 workers, octane:reload (4 rounds over the day) |
0 / 0 / 0 / 0 × HTTP 500 | 21 / 22 / 17 / 14 × HTTP 500 |
- With a 0 ms boot the window is only ~28 ms, so you rarely hit it. It grows with worker boot time, which is why real applications hit it on every reload.
- The 500s start 0.05–0.5 s after the PATCH, and each one returns in under 1 ms (
duration≈ 0.0001 s) withContent-Length: 0and only theServer: FrankenPHP Caddyheader. So the request is rejected immediately, not queued. - We saw 2 to 8 failed requests per reload at 20 req/s. That is every request arriving in that window.
Timeline of one reload (Laravel Octane setup, v1.13.0, debug log; timestamps are seconds after 1791409991):
.220 admin.api received request GET /config/apps/frankenphp
.226 admin.api received request PATCH /config/apps/frankenphp (Cache-Control: must-revalidate)
.227 admin admin endpoint started
.254 frankenphp PHP init of the new config begins (first PHP warning logged)
.327 http.log.error 500 "server is not registered ..." x4
.527 http.log.error 500 "server is not registered ..." x4
.553 frankenphp FrankenPHP started 🐘 {"php_version":"8.4.26","total_threads":32,"worker_threads":2,"max_threads":32,"max_requests":0}
.553 frankenphp FrankenPHP stopped 🐘
.553 http servers shutting down with eternal grace period
.747 first HTTP 200 again
.772 admin stopped previous server
From the source, Server.ServeHTTP returns ErrNotRunning when isRegistered is false (server.go, around line 152), and FrankenPHPModule.ServeHTTP turns every non-ErrRejected error into a 500 (caddy/module.go:229-232). It looks like during a reload the old HTTP server keeps accepting requests while the FrankenPHP server it points at has already been unregistered and the new one is not registered yet. On v1.12.7 those requests were served (or waited) instead of failing.
This may be related to #2648 ("hand off PHP requests during configuration reloads", which mentions 503s), #2645 (the same class of problem on the SIGTERM shutdown path, which explicitly leaves the reload path unchanged) and #2469. As far as we can tell, the 500 ErrNotRunning variant on reload is not tracked yet.
A smaller side note: with the Laravel setup, both versions also occasionally leave a request hanging (no response within 10 s) during a reload: 1 in ~1,800 requests on v1.12.7 and 7 in ~1,800 on v1.13.0. The minimal reproduction did not show this, so we are not sure it is the same issue.
Build Type
deb packages
Worker Mode
Yes
Operating System
GNU/Linux
CPU Architecture
x86_64
PHP configuration
phpinfo() output
FrankenPHP v1.13.0 PHP 8.4 Caddy v2.11.7 h1:yj0Y4fYZGPkSvibBJ1sTWE33xC0fxztVyXEW5iIdUT4= (go1.27.1)
deb: frankenphp 1.13.0+php84-1, php-zts-embed 8.4.26-2, php-zts-cli 8.4.26-2 (pkg.henderkes.com, "Static-PHP:php-zts")
Compared with:
FrankenPHP v1.12.7 PHP 8.4 Caddy v2.11.4 h1:XKxkMTgNSizEvKG6QHue6cAsFOteU2qA61w2tKkCWi0=
deb: frankenphp 1.12.7+php84-1, php-zts-embed 8.4.25-1
PHP 8.4.26, ZTS=1, ini: /etc/php-zts/php.ini (+ scan dir)
Extensions: Core date libxml openssl pcre zlib calendar ctype curl dom json fileinfo filter hash iconv SPL
mbstring pcntl session standard bz2 posix random readline Reflection exif SimpleXML sockets sodium tokenizer
xml xmlreader xmlwriter apcu bcmath brotli Phar ftp gd gettext gmp imagick intl ldap lz4 msgpack mysqlnd PDO
pgsql soap ssh2 tidy xsl yaml zip zstd igbinary memcached mysqli pdo_mysql pdo_pgsql redis Zend OPcache
(extension packages are still at 8.4.25 in the repository; the minimal worker uses none of them)
OS: Debian 12.15 (bookworm), kernel 6.1.0-53-amd64, 16 vCPU
Laravel setup: Laravel Framework 12.61.1, laravel/octane v2.17.4,
`php artisan octane:start --server=frankenphp --workers=2 --max-requests=500`
Relevant log output
Relevant log output
{"level":"error","ts":1791410386.07222,"logger":"http.log.error","msg":"server is not registered, you must first call frankenphp.Init() with the WithServer() option","request":{"remote_ip":"127.0.0.1","remote_port":"45880","client_ip":"127.0.0.1","proto":"HTTP/1.1","method":"GET","host":"127.0.0.1:3097","uri":"/","headers":{"User-Agent":["curl/7.88.1"],"Accept":["*/*"]}},"duration":0.000226745,"status":500,"err_id":"pp5za8t9u","err_trace":"caddy.(*FrankenPHPModule).ServeHTTP (module.go:231)"}
# HTTP response for such a request:
HTTP/1.1 500 Internal Server Error
Server: FrankenPHP Caddy
Content-Length: 0
- Langage dominant
- Go
- Étoiles
- 11.5k
- Forks
- 506
- Merge moyen
- 1 j 22 h
- PR mergées (30 j)
- 58
Préparer son environnement
- Fournit un Dockerfile ou un fichier Docker Compose
- Aucun modèle de pull request
- Lire le guide de contribution
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Autres issues de php/frankenphp
-
Difficulté 1/5 Moins d'une heure Accessibilité débutants 90/100
php/frankenphp#2671 · 1 commentaire ·
Les mainteneurs répondent en général sous 1 jour
-
Include frankenphp version in logsPeut-être à nouveau libre Une pull request pour cette issue a été fermée sans être fusionnée. Ouverteenhancement
Difficulté 2/5 1-3 heures Accessibilité débutants 68/100
php/frankenphp#2483 · 3 commentaires ·
Les mainteneurs répondent en général sous 1 jour
-
suggestion about compile.mdPeut-être à nouveau libre Une pull request pour cette issue a été fermée sans être fusionnée. Ouverteenhancement
Difficulté 1/5 1-3 heures Accessibilité débutants 68/100
php/frankenphp#601 · 5 commentaires ·
Les mainteneurs répondent en général sous 1 jour
-
Request bodies exceeding request_body max_size are silently truncated instead of returning 413 (classic and worker)Peut-être pris @dunglas l’a pris il y a 5 jours. Ouvertebug
Difficulté 4/5 3-5 jours Accessibilité débutants 55/100
php/frankenphp#2781 ·
Les mainteneurs répondent en général sous 1 jour
-
bug
Difficulté 4/5 3-5 jours Accessibilité débutants 45/100
php/frankenphp#2771 ·
Les mainteneurs répondent en général sous 1 jour
Toutes les issues de php/frankenphp
Issues similaires
-
go good first issue
Difficulté 2/5 1-3 heures Accessibilité débutants 82/100
Les mainteneurs répondent en général sous 1 jour
-
area: api bug severity:low
Difficulté 2/5 1-3 heures Accessibilité débutants 72/100
-
Difficulté 2/5 1-3 heures Accessibilité débutants 66/100
-
raised-by:desk to:worker
Difficulté 1/5 Moins d'une heure Accessibilité débutants 74/100
medici-finance/assay#5167 ·
Les mainteneurs répondent en général sous 1 jour
-
Response matcher: a changed integer above 2^53 passes because JSON numbers are compared as float64Ouverte
Difficulté 2/5 1-3 heures Accessibilité débutants 72/100
Les mainteneurs répondent en général sous 1 jour