Skip to content

Fix HttpStore write retries using the read endpoint's config#1751

Open
durvesh1992 wants to merge 1 commit into
react:mainfrom
durvesh1992:fix/httpstore-set-retry-config
Open

Fix HttpStore write retries using the read endpoint's config#1751
durvesh1992 wants to merge 1 commit into
react:mainfrom
durvesh1992:fix/httpstore-set-retry-config

Conversation

@durvesh1992

Copy link
Copy Markdown

Summary

HttpStore.#withRetries(fn, endpoint) is called for both endpoints — get() passes #getEndpoint, set() passes #setEndpoint — and it correctly consults the passed endpoint for the maxAttempts === 1 short-circuit. However, the backOff options hardcoded this.#getEndpoint for numOfAttempts, retryStatuses, and retryNetworkErrors.

As a result, when an HttpStore is constructed with the documented split { getOptions, setOptions } form, all set()/PUT retries silently use the read endpoint's retry configuration — setOptions.maxAttempts, setOptions.retryStatuses, and setOptions.retryNetworkErrors are ignored. There's also an internal inconsistency: the maxAttempts === 1 early-return reads the (set) endpoint, but numOfAttempts then read #getEndpoint.maxAttempts.

The fix uses the passed-in endpoint consistently.

Test plan

The existing retry tests only use the single-options form via get(), where #getEndpoint === #setEndpoint, so they can't catch this. Added a regression test that builds the store with the split form (reads: maxAttempts: 1; writes: maxAttempts: 2, retryStatuses: [503]) and asserts set() retries a 503:

  • Before: set() uses the read config (no retry) and throws the 503 → test fails.
  • After: set() retries per setOptions and resolves → test passes.
yarn jest packages/metro-cache/src/stores/__tests__/HttpStore-test.js
# Tests: 19 passed   (full metro-cache package: 45 passed)

HttpStore.#withRetries takes an `endpoint` parameter (get() passes
#getEndpoint, set() passes #setEndpoint) and correctly consults it for
the maxAttempts===1 short-circuit. But the backOff options hardcoded
this.#getEndpoint for numOfAttempts, retryStatuses, and
retryNetworkErrors. When the store is constructed with the documented
split { getOptions, setOptions } form, all set()/PUT retries silently
used the read endpoint's retry configuration (e.g. setOptions.maxAttempts
and setOptions.retryStatuses were ignored).

Use the passed-in `endpoint` consistently. Adds a regression test
exercising the split form on set() (the existing retry tests only use the
single-options form via get(), where the two endpoints are identical).
@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Jun 27, 2026
@facebook-github-tools facebook-github-tools Bot added the Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team. label Jun 27, 2026
@meta-codesync

meta-codesync Bot commented Jun 27, 2026

Copy link
Copy Markdown
Contributor

@robhogan has imported this pull request. If you are a Meta employee, you can view this in D109932333.

@robhogan robhogan 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.

Thanks, good find!

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

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants