mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-25 07:05:11 +00:00
fix(nuxt): pass DOMException
as fetch abort exception (#29058)
This commit is contained in:
parent
7071da8851
commit
2b73e1690c
@ -152,7 +152,7 @@ export function useFetch<
|
||||
let controller: AbortController
|
||||
|
||||
const asyncData = useAsyncData<_ResT, ErrorT, DataT, PickKeys, DefaultT>(key, () => {
|
||||
controller?.abort?.('Request aborted as another request to the same endpoint was initiated.')
|
||||
controller?.abort?.(new DOMException('Request aborted as another request to the same endpoint was initiated.', 'AbortError'))
|
||||
controller = typeof AbortController !== 'undefined' ? new AbortController() : {} as AbortController
|
||||
|
||||
/**
|
||||
@ -164,7 +164,7 @@ export function useFetch<
|
||||
const timeoutLength = toValue(opts.timeout)
|
||||
let timeoutId: NodeJS.Timeout
|
||||
if (timeoutLength) {
|
||||
timeoutId = setTimeout(() => controller.abort('Request aborted due to timeout.'), timeoutLength)
|
||||
timeoutId = setTimeout(() => controller.abort(new DOMException('Request aborted due to timeout.', 'AbortError')), timeoutLength)
|
||||
controller.signal.onabort = () => clearTimeout(timeoutId)
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user