Skip to content

Retry SDK resolve requests - #1152

Draft
jonathan-conder wants to merge 1 commit into
mainfrom
fix/store-tls-handshake-timeout
Draft

jonathan-conder wants to merge 1 commit into
mainfrom
fix/store-tls-handshake-timeout

Conversation

@jonathan-conder

Copy link
Copy Markdown
Contributor

Description

In CI I often see errors like this:
Post "https://api.pkg.store/v2/revisions/resolve": net/http: TLS handshake timeout.

This API happens to be a POST request even though it doesn't change anything on the server side. So it should be safe to retry when there's a potentially transient error.

Self-review quick check

  • Make decisions that cost a lot to reverse explicit in the PR description.
  • Avoid nested conditions.
  • Delete dead code and redundant comments.
  • Normalise symmetries by sticking to doing identical things identically.
// one way to handle errors
if err := f(); err != nil {
   ...
}

// one way to handle multiple returns
val, err := f()
if err != nil {
   ...
}
...
  • Check that coupled code elements, files, and directories are adjacent. For example, test data is stored as close as possible to a test.
  • Put variable declaration and initialisation together.
  • Divide large expressions into digestable and self-explanatory ones. Use multiple variables if required.
  • Put a blank line between two logically different chunks of code.
  • Follow the style guide for new error messages.

Docs

Procedure:

  • I have checked and added or updated relevant documentation.
  • I have checked and added or updated relevant release notes.
  • I have included the technical author in the review.

Content:

  • Headings and titles accurately describe the content.
  • New and updated pages include correct metadata.
  • Documentation tests are added or updated where applicable (for tutorial/ and how-to/ sections).
  • Documentation follows the style guide.
  • If needed, docs/.coverage.yaml updated, coverage tags added (.. artefact).

Or:

  • I confirm the PR has no implications for documentation.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The retry test leaves the successful response empty and discards the returned result, so it cannot detect a regression that returns an empty SDK list after a successful retry.

1 open issue
1 file not reviewed
  • internal/sdkstore/clock_mock_test.go: Generated file
What changed in this PR

This PR makes SDK resolution more resilient to transient network timeouts by explicitly retrying the store’s read-only POST requests.

Changes:

  • Add bounded, context-aware retries to SDK resolution.
  • Share network-error classification while preserving safe-method restrictions in HTTP middleware.
  • Add a timeout-retry test and a generated clock mock.
File Description
internal/​sdkstore/​resolve.go Retry transient network failures with fresh response state per attempt.
internal/​sdkstore/​resolve_test.go Test successful resolution after a timeout.
internal/​sdkstore/​package_test.go Add the clock mock generation directive.
internal/​sdkstore/​clock_mock_test.go Provide a generated clock mock for retry tests.
internal/​https/​middleware.go Export network-error classification for reuse by SDK resolution.

Review effort: Balanced

Comment on lines +84 to +99
gomock.InOrder(
restClient.EXPECT().Post(gomock.Any(), p, gomock.Any(), gomock.Any(), gomock.Any()).Return(restResponse{}, timeoutError{}),
restClient.EXPECT().Post(gomock.Any(), p, gomock.Any(), gomock.Any(), gomock.Any()).Return(restResponse{}, nil),
)

clockMock := NewMockClock(ctrl)
ch := make(chan time.Time, 1)
ch <- time.Now()
clockMock.EXPECT().Now().Return(time.Now()).AnyTimes()
clockMock.EXPECT().After(defaultRetryDelay).Return(ch).Times(1)

client := newResolveClient(p, restClient)
client.clock = clockMock

_, err := client.Resolve(context.Background(), transport.ResolveRequest{})
c.Assert(err, check.IsNil)
In CI I often see errors like this:
`Post "https://api.pkg.store/v2/revisions/resolve": net/http: TLS
handshake timeout`.

This API happens to be a POST request even though it doesn't change
anything on the server side. So it should be safe to retry when there's
a potentially transient error.
@jonathan-conder
jonathan-conder force-pushed the fix/store-tls-handshake-timeout branch from 0b186e0 to c23ec72 Compare November 12, 2026 07:43

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants