From 78244739fb7f800ab19c69e4470eba547352c828 Mon Sep 17 00:00:00 2001 From: Yogesh Vaishnav Date: Thu, 27 Nov 2025 21:45:16 +0530 Subject: [PATCH] fix: flush only active buffers in response stream --- src/Illuminate/Routing/ResponseFactory.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Illuminate/Routing/ResponseFactory.php b/src/Illuminate/Routing/ResponseFactory.php index a78459c47197..7c91102b347c 100644 --- a/src/Illuminate/Routing/ResponseFactory.php +++ b/src/Illuminate/Routing/ResponseFactory.php @@ -203,7 +203,7 @@ public function stream($callback, $status = 200, array $headers = []) return new StreamedResponse(function () use ($callback) { foreach ($callback() as $chunk) { echo $chunk; - ob_flush(); + when(ob_get_level() > 0, fn () => ob_flush()); flush(); } }, $status, array_merge($headers, ['X-Accel-Buffering' => 'no']));