From 667223ccd00551095cc64e1ef86de107a12bac7e Mon Sep 17 00:00:00 2001 From: Thorn Walli Date: Sun, 18 Aug 2024 13:31:08 +0200 Subject: [PATCH] fix(plugin): remove fetch retry, not necessary for object url --- src/tmpl/plugin.tmpl.js | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/src/tmpl/plugin.tmpl.js b/src/tmpl/plugin.tmpl.js index 4f4a710441..dd4d6218b5 100644 --- a/src/tmpl/plugin.tmpl.js +++ b/src/tmpl/plugin.tmpl.js @@ -59,13 +59,6 @@ export default defineNuxtPlugin({ const dimensionCache = new Map();`; } else { code += ` -function fetchRetry(url, options, retries = 3, delay = 300) { - return fetch(url, options).catch(function (error) { - if (retries <= 0) throw error; - return new Promise(resolve => setTimeout(resolve, delay)).then(() => fetchRetry(url, options, retries - 1, delay)); - }); -} - const dimensionCache = new NodeCache({ stdTTL: 60 * 60 * 24, checkperiod: 60 * 60 * 1, useClones: false });`; } @@ -102,7 +95,7 @@ async function getImageSize (src) { ); const objectUrl = URL.createObjectURL(blob); - const data = await fetchRetry(objectUrl, undefined, 3).then(async res => + const data = await fetch(objectUrl).then(async res => Buffer.from(await res.arrayBuffer()) ); const dimension = await imageMeta(data);