From 4d178bdad6a63513115e33e04f7d8747089251e3 Mon Sep 17 00:00:00 2001 From: Lito Date: Mon, 10 Apr 2023 15:53:40 +0200 Subject: [PATCH] Fixed server Closing on invalid `$requestPort` (#46726) On a docker deploy I get a random `Undefined array key` when try to manage the `Closing` server response on a undefined `$requestPort`. Maybe the problem is `getRequestPortFromLine` parse, but for now maybe the best option is check the `$this->requestsPool[$requestPort]` before continue with the output. --- src/Illuminate/Foundation/Console/ServeCommand.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/Illuminate/Foundation/Console/ServeCommand.php b/src/Illuminate/Foundation/Console/ServeCommand.php index 9a27fa459644..b966291f3ab0 100644 --- a/src/Illuminate/Foundation/Console/ServeCommand.php +++ b/src/Illuminate/Foundation/Console/ServeCommand.php @@ -251,9 +251,12 @@ protected function handleProcessOutput() $this->requestsPool[$requestPort][1] = trim(explode('[200]: GET', $line)[1]); } elseif (str($line)->contains(' Closing')) { $requestPort = $this->getRequestPortFromLine($line); - $request = $this->requestsPool[$requestPort]; - [$startDate, $file] = $request; + if (empty($this->requestsPool[$requestPort])) { + return; + } + + [$startDate, $file] = $this->requestsPool[$requestPort]; $formattedStartedAt = $startDate->format('Y-m-d H:i:s');