From 5c6b92c70dcbb016e2af8503708b076bee6efd11 Mon Sep 17 00:00:00 2001 From: Alain Belair Date: Sun, 24 Mar 2024 14:38:00 -0400 Subject: [PATCH 1/3] fix js version --- app-test/_includes/AppTest.php | 1 + 1 file changed, 1 insertion(+) diff --git a/app-test/_includes/AppTest.php b/app-test/_includes/AppTest.php index 6053f37..31e6ef5 100644 --- a/app-test/_includes/AppTest.php +++ b/app-test/_includes/AppTest.php @@ -30,6 +30,7 @@ public static function createPage(string $environment = 'production'): Page ]); if ($environment === 'dev') { + $page->fohnJsVersion = ''; $page->includeJsPackage('fohn-js', '/public/fohn-ui.js'); $page->includeCssPackage('fohn-css', '/public/fohn-ui.css'); } From 3da648cbc1b3ef15fed8f6598c321eb6d3bbcff6 Mon Sep 17 00:00:00 2001 From: Alain Belair Date: Sun, 24 Mar 2024 14:39:11 -0400 Subject: [PATCH 2/3] fix server side event allow increase event size to a minimum size for phpfpm --- src/App.php | 3 +++ src/Callback/ServerEvent.php | 8 +++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/App.php b/src/App.php index 0d8f375..ebc908e 100644 --- a/src/App.php +++ b/src/App.php @@ -186,6 +186,8 @@ public function prepareEventStreaming(int $limit = 0, bool $ignoreUserAbort = tr { @set_time_limit($limit); ignore_user_abort($ignoreUserAbort); + @ini_set('zlib.output_compression', '0'); + $response = (new Response()) ->withHeader('Content-Type', 'text/event-stream') @@ -194,5 +196,6 @@ public function prepareEventStreaming(int $limit = 0, bool $ignoreUserAbort = tr ->withStatus(200); $this->emitter->emit($response); + } } diff --git a/src/Callback/ServerEvent.php b/src/Callback/ServerEvent.php index fab1d14..a5f18e7 100644 --- a/src/Callback/ServerEvent.php +++ b/src/Callback/ServerEvent.php @@ -38,6 +38,12 @@ class ServerEvent extends Generic /** Keep execution alive or not if connection is close by user. False mean that execution will stop on user aborted. */ public bool $keepAlive = false; + /** + * The min size of event stream data to be output. + * Set it to 4096 when using phpfpm. + */ + public int $minBufferSize = 0; + /** Check if ServerEvent callback has been request and executed. */ private bool $requestSet = false; @@ -127,7 +133,7 @@ protected function sendBlock(string $id, string $event, string $name): void $streamEvent = [ 'id: ' . $id . "\n", 'event: ' . $name . "\n", - 'data' => $this->wrapEvent($event) . "\n", + 'data' => $this->wrapEvent(str_pad($event, $this->minBufferSize)) . "\n", ]; $this->app->streamEvent($streamEvent); From 79168e2c1cc8ca36fa04d1e583aade774d4cdc50 Mon Sep 17 00:00:00 2001 From: Alain Belair Date: Sun, 24 Mar 2024 15:05:01 -0400 Subject: [PATCH 3/3] cs fix --- src/App.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/App.php b/src/App.php index ebc908e..2beed95 100644 --- a/src/App.php +++ b/src/App.php @@ -188,7 +188,6 @@ public function prepareEventStreaming(int $limit = 0, bool $ignoreUserAbort = tr ignore_user_abort($ignoreUserAbort); @ini_set('zlib.output_compression', '0'); - $response = (new Response()) ->withHeader('Content-Type', 'text/event-stream') ->withHeader('Cache-Control', 'no-cache') @@ -196,6 +195,5 @@ public function prepareEventStreaming(int $limit = 0, bool $ignoreUserAbort = tr ->withStatus(200); $this->emitter->emit($response); - } }