From 36fb381baeb81a82e5d3938971fa735f941ee0c1 Mon Sep 17 00:00:00 2001 From: Florent De Neve Date: Thu, 31 Jul 2025 15:12:15 +0300 Subject: [PATCH 1/2] Gracefully handle EINPROGRESS --- src/Client.php | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/src/Client.php b/src/Client.php index 8e4a641..5be943f 100644 --- a/src/Client.php +++ b/src/Client.php @@ -552,7 +552,29 @@ private function sendRawRequest(string $host, int $port, string $rawRequest) @socket_connect($this->socket, $host, $port); $socketErrorCode = socket_last_error($this->socket); if ($socketErrorCode === 115) { - $this->logger->info('Bedrock\Client - socket_connect returned error 115, continuing.'); + $this->logger->info('Bedrock\Client - socket_connect returned EINPROGRESS, waiting for connection to complete'); + + // Use select to wait for the socket to become writable (indicates connection completion) + $write = [$this->socket]; + $read = null; + $except = null; + + $selectResult = socket_select($read, $write, $except, $this->connectionTimeout, $this->connectionTimeoutMicroseconds); + if ($selectResult === false) { + $socketError = socket_strerror(socket_last_error()); + throw new ConnectionFailure("Failed to select on socket for host $host:$port. Error: $socketError"); + } elseif ($selectResult === 0) { + throw new ConnectionFailure("Connection timeout while waiting for EINPROGRESS completion for host $host:$port"); + } + + // Check if connection completed successfully + $connectionError = socket_get_option($this->socket, SOL_SOCKET, SO_ERROR); + if ($connectionError !== 0) { + $socketError = socket_strerror($connectionError); + throw new ConnectionFailure("Connection failed after EINPROGRESS for host $host:$port. Error: $connectionError $socketError"); + } + + $this->logger->info('Bedrock\Client - EINPROGRESS connection completed successfully'); } elseif ($socketErrorCode) { $socketError = socket_strerror($socketErrorCode); throw new ConnectionFailure("Could not connect to Bedrock host $host:$port. Error: $socketErrorCode $socketError"); From 0a22a644be3c4ead8113497dbb27cb09f0e9b4a5 Mon Sep 17 00:00:00 2001 From: Florent De Neve Date: Mon, 4 Aug 2025 16:18:40 +0300 Subject: [PATCH 2/2] Version 2.1.3 --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index ecbe17d..52c166c 100644 --- a/composer.json +++ b/composer.json @@ -2,7 +2,7 @@ "name": "expensify/bedrock-php", "description": "Bedrock PHP Library", "type": "library", - "version": "2.1.2", + "version": "2.1.3", "authors": [ { "name": "Expensify",