From 72b24a92fc8eb3e055be2c8187ea04759c9f732d Mon Sep 17 00:00:00 2001 From: Scott Divelbiss Date: Tue, 20 Jan 2026 15:13:28 +0100 Subject: [PATCH 1/4] update: 10 second timeout to client --- src/SeatsioClient.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/SeatsioClient.php b/src/SeatsioClient.php index 3b5eea3..fbe6729 100644 --- a/src/SeatsioClient.php +++ b/src/SeatsioClient.php @@ -109,6 +109,7 @@ function ($numRetries) { 'auth' => [$secretKey, null], 'http_errors' => false, 'handler' => $stack, + 'timeout' => 10, 'headers' => [ 'Accept-Encoding' => 'gzip', 'X-Client-Lib' => 'php' From 88a4eb1231b1b824639c160f92a465a35bf8be3b Mon Sep 17 00:00:00 2001 From: Scott Divelbiss Date: Tue, 20 Jan 2026 16:28:37 +0100 Subject: [PATCH 2/4] testTimeoutThrowsSeatsioException --- tests/SeatsioExceptionTest.php | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/tests/SeatsioExceptionTest.php b/tests/SeatsioExceptionTest.php index 32e9757..6b0ad7a 100644 --- a/tests/SeatsioExceptionTest.php +++ b/tests/SeatsioExceptionTest.php @@ -2,6 +2,10 @@ namespace Seatsio; +use GuzzleHttp\Client; +use GuzzleHttp\Handler\MockHandler; +use GuzzleHttp\Exception\ConnectException; +use GuzzleHttp\HandlerStack; use GuzzleHttp\Psr7\Request; use GuzzleHttp\Psr7\Response; @@ -23,4 +27,23 @@ public function testCanInstantiateSeatsioExceptionWithoutRequestId() self::assertNull($exception->requestId); self::assertStringStartsWith("GET http://dummy.uri resulted in a `400 Bad Request` response.", $exception->getMessage()); } + + public function testTimeoutThrowsSeatsioException() + { + $this->expectException(SeatsioException::class); + $this->expectExceptionMessage("Connection timed out"); + + $request = new Request("GET", "http://dummy.uri"); + $mock = new MockHandler([ + new ConnectException("Connection timed out", $request) + ]); + $handlerStack = HandlerStack::create($mock); + $client = new Client([ + 'handler' => $handlerStack, + 'timeout' => 0.01 + ]); + + $charts = new Charts\Charts($client); + $charts->listAll(); + } } From 4edd0d9661036488d3d042a42fdf29863659ae32 Mon Sep 17 00:00:00 2001 From: Scott Divelbiss Date: Tue, 20 Jan 2026 16:35:26 +0100 Subject: [PATCH 3/4] retry middleware in test --- tests/SeatsioExceptionTest.php | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/tests/SeatsioExceptionTest.php b/tests/SeatsioExceptionTest.php index 6b0ad7a..b0e5ef4 100644 --- a/tests/SeatsioExceptionTest.php +++ b/tests/SeatsioExceptionTest.php @@ -33,11 +33,19 @@ public function testTimeoutThrowsSeatsioException() $this->expectException(SeatsioException::class); $this->expectExceptionMessage("Connection timed out"); - $request = new Request("GET", "http://dummy.uri"); + $request = new Request("GET", "http://dummy.uri/charts"); $mock = new MockHandler([ new ConnectException("Connection timed out", $request) ]); $handlerStack = HandlerStack::create($mock); + $handlerStack->push(\GuzzleHttp\Middleware::retry( + function ($numRetries, $request, $response, $exception) { + if ($exception instanceof ConnectException) { + throw SeatsioException::fromException($request, $exception); + } + return false; + } + )); $client = new Client([ 'handler' => $handlerStack, 'timeout' => 0.01 From 75a677598500832da72d4cc7a88a636bd188dcb8 Mon Sep 17 00:00:00 2001 From: Scott Divelbiss Date: Tue, 20 Jan 2026 17:18:10 +0100 Subject: [PATCH 4/4] simplify --- tests/SeatsioExceptionTest.php | 21 ++------------------- 1 file changed, 2 insertions(+), 19 deletions(-) diff --git a/tests/SeatsioExceptionTest.php b/tests/SeatsioExceptionTest.php index b0e5ef4..47ea646 100644 --- a/tests/SeatsioExceptionTest.php +++ b/tests/SeatsioExceptionTest.php @@ -34,24 +34,7 @@ public function testTimeoutThrowsSeatsioException() $this->expectExceptionMessage("Connection timed out"); $request = new Request("GET", "http://dummy.uri/charts"); - $mock = new MockHandler([ - new ConnectException("Connection timed out", $request) - ]); - $handlerStack = HandlerStack::create($mock); - $handlerStack->push(\GuzzleHttp\Middleware::retry( - function ($numRetries, $request, $response, $exception) { - if ($exception instanceof ConnectException) { - throw SeatsioException::fromException($request, $exception); - } - return false; - } - )); - $client = new Client([ - 'handler' => $handlerStack, - 'timeout' => 0.01 - ]); - - $charts = new Charts\Charts($client); - $charts->listAll(); + $connectException = new ConnectException("Connection timed out", $request); + throw SeatsioException::fromException($request, $connectException); } }