Skip to content

Improve response parser and retry logic#96

Merged
MattCCC merged 4 commits intomasterfrom
fix-response-parser
Jul 30, 2025
Merged

Improve response parser and retry logic#96
MattCCC merged 4 commits intomasterfrom
fix-response-parser

Conversation

@MattCCC
Copy link
Owner

@MattCCC MattCCC commented Jul 30, 2025

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:

  • Updated the parseResponseData function in src/response-parser.ts to 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:

  • Modified the withRetry function in src/retry-handler.ts to 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:

  • Added a new test case in test/react/integration/hook.spec.tsx to 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))
  • Introduced a dedicated test file, 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))

@github-actions
Copy link

github-actions bot commented Jul 30, 2025

size-limit report 📦

Path Size
dist/browser/index.mjs 5.38 KB (-0.08% 🔽)
dist/browser/index.global.js 5.54 KB (-0.2% 🔽)
dist/node/index.js 5.45 KB (-0.11% 🔽)
dist/react/index.mjs 8.41 KB (-0.09% 🔽)
dist/react/index.js 9.13 KB (-0.08% 🔽)

@MattCCC MattCCC self-assigned this Jul 30, 2025
@MattCCC MattCCC added the bug Something isn't working label Jul 30, 2025
Copy link
Collaborator

@devdgna devdgna left a comment

Choose a reason for hiding this comment

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

+1

@MattCCC MattCCC merged commit d21a39a into master Jul 30, 2025
10 checks passed
@MattCCC MattCCC deleted the fix-response-parser branch July 30, 2025 16:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants