Closed johnnyshankman closed 2 years ago
Can you try again using today's 0.6.0 release to determine if there's any noticeable difference?
I use this library in my brander library to generate hundreds of assets consecutively and haven't experience this issue. That said; I notice that you're using the main convert
method which creates a new instance of Chromium each time it's called. It's strongly recommended that you use createConverter
to create a single Chromium instance but make sure you destroy
it once you're done to free up resources (i.e. kills the orphaned Chromium instance).
For example;
const { createConverter } = require('convert-svg-to-png');
const { readdir } = require('fs/promises');
async function convertSvgFiles(dirPath) {
const converter = createConverter();
try {
const filePaths = await readdir(dirPath);
for (const filePath of filePaths) {
await converter.convertFile(filePath);
}
} finally {
await converter.destroy();
}
}
Please let me know how you get on.
@neocotic great advice! I didn't know about the createConverter
optimization not did I realize I should be destroy()
ing after every usage. I think this will fix everything alone, but I'll also try the update as well. Thank you so much.
Let me know how you get on and hopefully we can close this issue out 🤘
Error:
Setup:
Create a for loop that does this over and over again.