Skip to content

Commit

Permalink
fix(plugin): remove fetch retry, not necessary for object url
Browse files Browse the repository at this point in the history
  • Loading branch information
ThornWalli committed Aug 18, 2024
1 parent dfe4c5a commit 667223c
Showing 1 changed file with 1 addition and 8 deletions.
9 changes: 1 addition & 8 deletions src/tmpl/plugin.tmpl.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 });`;
}

Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 667223c

Please sign in to comment.