Improve response parser and retry logic#96
Merged
Conversation
size-limit report 📦
|
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.
This pull request introduces several updates to enhance response handling, improve retry logic, and add comprehensive React integration tests for POST body cache key updates. The most important changes include refining response parsing, optimizing retry behavior, and adding new test cases to ensure robust functionality.
Improvements to response handling:
parseResponseDatafunction insrc/response-parser.tsto simplify the null-check logic, ensuring early bail-out if the response is null or undefined. ([src/response-parser.tsL36-R37](https://github.com/MattCCC/fetchff/pull/96/files#diff-97e3cd5bba7d4c11711764da1f6ef23ac92ddb501c128d56a6cb8ef9fbadf3c2L36-R37))Enhancements to retry logic:
withRetryfunction insrc/retry-handler.tsto optimize performance by passing the correct stale revalidation flag based on the current attempt number. ([src/retry-handler.tsL143-R146](https://github.com/MattCCC/fetchff/pull/96/files#diff-04bf635c85ebe8501d4c9012c897b82735c289e4c6acea39d00495363a1a19d4L143-R146))Additions to React integration tests:
test/react/integration/hook.spec.tsxto verify that the cache key is regenerated and the updated POST body is used when refetching. This ensures that changes in the request body are correctly reflected in subsequent API calls. ([test/react/integration/hook.spec.tsxR1665-R1740](https://github.com/MattCCC/fetchff/pull/96/files#diff-c0a889a6a01eb10df459bfee63587049bef683dd842fff4337882ef396b18fdbR1665-R1740))test/react/integration/post-body-cache-key.spec.tsx, to validate POST body updates and their effect on cache keys, UI state, and refetch behavior. This test ensures consistent behavior with static cache keys and dynamic request bodies. ([test/react/integration/post-body-cache-key.spec.tsxR1-R67](https://github.com/MattCCC/fetchff/pull/96/files#diff-cfd4cbca98162d0e540d8f83e5c54b5d003a0c279914549e5db77189d0cb53b2R1-R67))