Summary
The SDK's default API request timeout is 30 seconds, and there is no separate connect timeout. This is too long for calls made in a frontend/user-facing context (e.g. the Magento extension calls the SDK on add-to-cart), where a slow or unreachable API can block a request for the full 30s and tie up web/PHP workers under load.
Details
Sdk.php sets api_request_timeout => 30 by default, passed to Http.php and applied as Guzzle RequestOptions::TIMEOUT.
Http.php sets RequestOptions::TIMEOUT only — it never sets RequestOptions::CONNECT_TIMEOUT, so there is no fast-fail when the API host cannot be reached.
Proposed changes
Notes
- A Guzzle timeout raises
ConnectException / RequestException, which is not response-based and is therefore not represented by the SDK's HttpException (which requires a ResponseInterface). Consumers catching only HttpException will not catch a timeout. Worth documenting the exception surface for timeouts, or wrapping it.
Related
Summary
The SDK's default API request timeout is 30 seconds, and there is no separate connect timeout. This is too long for calls made in a frontend/user-facing context (e.g. the Magento extension calls the SDK on add-to-cart), where a slow or unreachable API can block a request for the full 30s and tie up web/PHP workers under load.
Details
Sdk.phpsetsapi_request_timeout => 30by default, passed toHttp.phpand applied as GuzzleRequestOptions::TIMEOUT.Http.phpsetsRequestOptions::TIMEOUTonly — it never setsRequestOptions::CONNECT_TIMEOUT, so there is no fast-fail when the API host cannot be reached.Proposed changes
api_request_timeout(30s is high for a synchronous, user-facing call).RequestOptions::CONNECT_TIMEOUT), plumbed throughSdk.phpconfig →Http.php→ the Guzzle client, so consumers can fast-fail on unreachable hosts independently of the total request timeout.Notes
ConnectException/RequestException, which is not response-based and is therefore not represented by the SDK'sHttpException(which requires aResponseInterface). Consumers catching onlyHttpExceptionwill not catch a timeout. Worth documenting the exception surface for timeouts, or wrapping it.Related