BRD-1239: add connect timeout and idempotent-only retry to the HTTP clients - #81
Open
rokaszygmantas wants to merge 1 commit into
Open
BRD-1239: add connect timeout and idempotent-only retry to the HTTP clients#81rokaszygmantas wants to merge 1 commit into
rokaszygmantas wants to merge 1 commit into
Conversation
Bulk syncs were cancelled mid-flight during the nightly peak and a single transient 502 cost the caller a full queue-level retry. The transports set only CURLOPT_TIMEOUT (30s) and had no retry at all. - Move the cURL call behind a Transport interface with an HttpRequest that carries both timeouts; CurlTransport sets CURLOPT_CONNECTTIMEOUT. - HttpClient retries transport errors, 5xx and 429 for idempotent calls using RetryPolicy (3 attempts, 1s doubling to 8s, equal jitter). POST is non-idempotent unless the facade passes idempotent: true; only bulk-operations, V1 sync/delete-products and normalize do. - SyncConfig, SyncConfigV2 and MagentoConfig gain connectTimeout (10s); SyncConfigV2 also gains timeout and retryPolicy and forwards them. - AdminHttpClient wraps HttpClient so admin calls share the policy. - TransportException extends ApiException (status 0) for no-response failures, so existing catch blocks keep working. - SyncV2Sdk and AdminSdk accept an optional Transport for tests. Tests script responses through a fake transport and sleeper; no network, no real sleeps.
Member
Author
|
Consumer half: Invertus/brad-app#565 pins this branch at 3d5c55e as 4.16.0 until the tag exists. Suggested tag after merge: v4.16.0. |
rokaszygmantas
marked this pull request as ready for review
September 3, 2026 07:31
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Ticket: BRD-1239
Summary
SyncConfigV2finally exposes both, so brad-app can size bulk calls above the 30s default.Transportinterface so the retry loop is unit-tested with a scripted fake;TransportException extends ApiExceptionkeeps existing catch blocks working.Proof
No UI surface; browser QA does not apply to a PHP library.
Real-network smoke against a non-routable IP with
connectTimeout: 2,RetryPolicy::none():Acceptance criteria evidence
CURLOPT_CONNECTTIMEOUTfrom config, default 10sHttpClientRetryTest::testRequestCarriesTimeoutsHeadersAndBody,SyncV2SdkTransportTest::testDefaultsAreThirtySecondReadAndTenSecondConnect,AdminSdkTransportTest::testAdminHeaderAndTimeoutsReachTheTransport; Magento client viaConnectTimeoutConfigTest::testMagentoConfigHasConnectTimeoutplus the smoke run aboveSyncConfig,SyncConfigV2,MagentoConfigaccept optionalconnectTimeout/timeout;SyncV2Sdkforwards them; existing callers compile unchangedConnectTimeoutConfigTest(defaults, positional callers, validation),SyncV2SdkTransportTest::testTimeoutsAndAuthReachTheTransport, full existing suite greenHttpClientRetryTest::testRetriesIdempotentCallOn502ThenSucceeds,::testRetriesIdempotentCallOn429,::testRetriesIdempotentCallOnTransportError,::testRetriesPostFlaggedIdempotent,::testDoesNotRetryNonIdempotentPostOn503,SyncV2SdkTransportTest::testBulkOperationsIsRetriedOn503,::testConfigurationRefreshIsNotRetriedOn503HttpClientRetryTest::testDoesNotRetryOn400,RetryPolicyTest::testRetryableStatusesHttpClientRetryTest::testThrowsLastResponseWhenAttemptsExhausted,::testThrowsLastTransportErrorWhenAttemptsExhaustedtests/Client/Support/FakeTransport.php,FakeSleeper.php;HttpClientRetryTest::testBackoffDelaysStayWithinJitterBounds,RetryPolicyTest::testDelayGrowsExponentiallyWithEqualJitterAndCapAC-7 to AC-13 belong to the brad-app half of the ticket and ship in a separate PR after this one is tagged.
Details
HttpClient::post(), not a path rule. The facade marks bulk-operations, V1 sync/delete-products and normalize; everything else that POSTs stays single-attempt. This is the one place a future endpoint has to make a conscious choice.[d/2, d]) rather than full jitter, so the minimum wait still grows and tests can assert bounds.Retry-Afterparsing. brad-search does not emit it today; add when it does.MagentoGraphQLClientgets the connect timeout only, no retry. It talks to merchant stores, and retry policy for store APIs is BRD-1206's concern.curl_close()dropped in the newCurlTransport: no-op since PHP 8.0, deprecated in 8.5. Left untouched in the Magento client.v4.16.0.Confidence: 4/5 - every SDK criterion has a named test and the real cURL path was smoke-tested, but the backoff timing only ran against the fake sleeper, never a real stalled brad-search.