Revert "Remove malloc(): corrupted top size workaround"

This reverts commit ac3dbe0178.
This commit is contained in:
Christopher Monsanto
2021-12-22 16:16:45 -05:00
parent 0c037206f6
commit 7aa58c8e86

View File

@@ -38,8 +38,15 @@ const proc = cp.spawn("magick", [
stdio: ['pipe', 'inherit', 'inherit']
});
// Write one at a time to avoid "malloc(): corrupted top size" error
for (const entry of sheet.entries) {
proc.stdin.write(entry + "\n");
if (!proc.stdin.write(entry + "\n")) {
// imagick doesn't like it when it receives the input too fast. This
// seems to avoid a realloc() invalid next size error.
await new Promise(resolve => {
proc.stdin.once('drain', resolve);
});
}
}
proc.stdin.end();