From 87972f39b9058e9ee7e805aa7a2c53ce75032eb5 Mon Sep 17 00:00:00 2001 From: Adhik Joshi Date: Fri, 21 Aug 2026 13:38:34 +0530 Subject: [PATCH] Log timeout-sweep arming at boot; read env in the packaged config Production frontend showed zero sweep activity across days of 210s stalls while the identical build enforced budgets perfectly in local prod-topology tests - and nothing observable distinguished 'armed but never triggered' from 'never armed'. One error_log line at boot now states the effective max_execution_time and sweep interval, and a warning fires when the sweep resolves disabled. The packaged config also hardcoded max_execution_time=30 with no env read, so any app without a published octane config silently ignored OCTANE_MAX_EXECUTION_TIME - which is also why two local repros of the prod stall were invalid until caught. --- config/octane.php | 2 +- src/Swoole/Handlers/OnServerStart.php | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/config/octane.php b/config/octane.php index 7fcf568..2b503f1 100644 --- a/config/octane.php +++ b/config/octane.php @@ -362,6 +362,6 @@ | */ - 'max_execution_time' => 30, + 'max_execution_time' => env('OCTANE_MAX_EXECUTION_TIME', 30), ]; diff --git a/src/Swoole/Handlers/OnServerStart.php b/src/Swoole/Handlers/OnServerStart.php index 179f158..bf00794 100644 --- a/src/Swoole/Handlers/OnServerStart.php +++ b/src/Swoole/Handlers/OnServerStart.php @@ -60,11 +60,18 @@ public function __invoke($server) } if ($this->maxExecutionTime > 0) { + // One line per boot so production can never silently run without + // request-timeout enforcement again - chasing the 210s stalls + // burned hours on exactly the question this answers. + error_log("⏱️ Timeout sweep armed: max_execution_time={$this->maxExecutionTime}s, interval={$this->timeoutSweepIntervalMs}ms"); + Timer::tick($this->timeoutSweepIntervalMs, function () use ($server) { (new EnsureRequestsDontExceedMaxExecutionTime( $this->extension, $this->timerTable, $this->maxExecutionTime, $server, $this->timeoutFallbackSignal ))(); }); + } else { + error_log('⚠️ Timeout sweep DISABLED: max_execution_time resolved to 0 - requests can run unbounded'); } } }