From 2b73e1690c38ee8447cdfb767f03365cddec75d5 Mon Sep 17 00:00:00 2001 From: DarkVen0m Date: Wed, 18 Sep 2024 22:21:18 +0300 Subject: [PATCH] fix(nuxt): pass `DOMException` as fetch abort exception (#29058) --- packages/nuxt/src/app/composables/fetch.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/nuxt/src/app/composables/fetch.ts b/packages/nuxt/src/app/composables/fetch.ts index 093554f82b..5ce5a87d1f 100644 --- a/packages/nuxt/src/app/composables/fetch.ts +++ b/packages/nuxt/src/app/composables/fetch.ts @@ -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) }