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

fix(useFetch): don't set isFetching to false when a request is aborted because of a refetch #3479

Merged
merged 4 commits into from Nov 9, 2023
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 7 additions & 1 deletion packages/core/useFetch/index.ts
Expand Up @@ -397,13 +397,18 @@
if (timeout)
timer = useTimeoutFn(abort, timeout, { immediate: false })

let executeCounter = 0

Check failure on line 401 in packages/core/useFetch/index.ts

View workflow job for this annotation

GitHub Actions / lint

Trailing spaces not allowed
const execute = async (throwOnFailed = false) => {
abort()

loading(true)
error.value = null
statusCode.value = null
aborted.value = false

Check failure on line 409 in packages/core/useFetch/index.ts

View workflow job for this annotation

GitHub Actions / lint

Trailing spaces not allowed
executeCounter += 1
const currentExecuteCounter = executeCounter

const defaultFetchOptions: RequestInit = {
method: config.method,
Expand Down Expand Up @@ -506,7 +511,8 @@
return resolve(null)
})
.finally(() => {
loading(false)
if (currentExecuteCounter === executeCounter)
loading(false)
if (timer)
timer.stop()
finallyEvent.trigger(null)
Expand Down