Closed paintoshi closed 2 years ago
Found a solution. Creating and destroying puppeteer on every conversion allows async conversion without conflicts.
https://github.com/neocotic/convert-svg/tree/main/packages/convert-svg-to-png#createconverteroptions
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();
}
}
I'm using the library to convert thousands of svgs in an async function. But running into problems, where some just fail. Others get corrupted and I see an array of svgs in the same output image coming from other svgs. Like it's overwriting itself by colliding in memory or on disk. Could it be the temp file that is the problem here? And is there anything I can do about it?