Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: process images for resizing more reliably #11281

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

r1tsuu
Copy link
Member

@r1tsuu r1tsuu commented Feb 19, 2025

Before, we did image resizing in parallel. Meaning if you have 10 different sizes, the machine would process all those at the same time, which potentially can lead to issues with memory, increased CPU usage and unexpected crashes, as the image resizing process is expensive unless you offload it to a different server, which we don't support.

This PR changes to do that sequentially, which could be slower, but more reliable overall which is more important.

Additionally, modifies this call:

if (await fileExists(imagePath)) {
  try {
    fs.unlinkSync(imagePath)
  } catch {
    // Ignore unlink errors
  }
}

to

void fileExists(imagePath).then((value) => {
  if (value) {
    void fs.promises.unlink(imagePath)
  }
})

As we don't really need to await it or block the thread with unlinkSync.

Fixes #8592

@r1tsuu r1tsuu force-pushed the fix/more-reliable-image-processing branch from 7f6a3ec to 9a5dfda Compare February 19, 2025 15:24
@r1tsuu r1tsuu requested a review from DanRibbens February 19, 2025 15:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

OOM Crashes During Image Resizing
1 participant