Skip to content

Reduce default API request timeout and add connect-timeout support #56

Description

@chrismshea

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

  • Reconsider the default api_request_timeout (30s is high for a synchronous, user-facing call).
  • Add support for a separate connect timeout (RequestOptions::CONNECT_TIMEOUT), plumbed through Sdk.php config → Http.php → the Guzzle client, so consumers can fast-fail on unreachable hosts independently of the total request timeout.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions