Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: request cancellation #106

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open

Conversation

logaretm
Copy link
Owner

@logaretm logaretm commented Mar 6, 2021

This PR brings AbortController support to cancel ongoing requests.

Aside from that, if the same query/mutation triggered multiple requests, it will be canceled by default.

The only problem is to workout the interaction between cancellation and dedup and batch plugins.

For dedup it is problematic to cancel a deduped request because that means it would cancel for other queries as well. There isn't a lot of options here other than "avoid" deduped requests abort signal to prevent mistakes.

For batch, that would cancel the whole batched request. I don't think I have much choice here other than not supporting cancellation with batch.

closes #90

@logaretm logaretm force-pushed the feat/abort-redudant-operations branch 3 times, most recently from 9ecaca7 to ad5c0ff Compare March 7, 2021 19:32
@logaretm logaretm force-pushed the feat/abort-redudant-operations branch from ad5c0ff to dc4a99a Compare August 7, 2021 20:08
@codecov-commenter
Copy link

Codecov Report

Merging #106 (dc4a99a) into main (319dd44) will decrease coverage by 2.16%.
The diff coverage is 70.21%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #106      +/-   ##
==========================================
- Coverage   94.67%   92.51%   -2.17%     
==========================================
  Files          26       26              
  Lines         526      561      +35     
  Branches       94      106      +12     
==========================================
+ Hits          498      519      +21     
- Misses         28       42      +14     
Impacted Files Coverage Δ
packages/villus/src/utils/common.ts 80.00% <50.00%> (-12.86%) ⬇️
packages/villus/src/fetch.ts 96.00% <66.66%> (-4.00%) ⬇️
packages/villus/src/useMutation.ts 84.21% <68.75%> (-12.09%) ⬇️
packages/villus/src/useQuery.ts 91.35% <72.22%> (-5.71%) ⬇️
packages/villus/src/client.ts 100.00% <100.00%> (ø)
packages/villus/src/utils/error.ts 93.75% <100.00%> (+0.41%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 319dd44...dc4a99a. Read the comment docs.

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.

Canceling a request
2 participants