Niels-IO / next-image-export-optimizer

Use Next.js advanced <Image/> component with the static export functionality. Optimizes all static images in an additional step after the Next.js static export.
MIT License
439 stars 52 forks source link

Download remote images error at specific number of images #161

Closed thuatz closed 1 year ago

thuatz commented 1 year ago

View: src/utils/downloadImagesInBatches.ts Function: downloadImagesInBatches

const batches = Math.ceil(imagesURLs.length / batchSize); // determine the number of batches

for (let i = 0; i < batches; i++) {

    const start = i * batchSize; // calculate the start index of the batch

    const end = Math.min(imagesURLs.length, start + batchSize); // calculate the end index of the batch

    const batchURLs = imagesURLs.slice(start, end); // slice the URLs for the current batch

    const batchFileNames = imageFileNames.slice(start, end); // slice the file names for the current batch

    if (batchFileNames[i].fullPath === undefined) {`

If 231 images, we have 12 batches. Then last patch has only 11 images (index from 0 to 10). Then it throws error at i = 11

Niels-IO commented 1 year ago

Hi @thuatz, Thanks for the error report. I opened a PR for a fix