From 7aa58c8e86b24b2e99d4d1b4629c03b668c15d8c Mon Sep 17 00:00:00 2001 From: Christopher Monsanto Date: Wed, 22 Dec 2021 16:16:45 -0500 Subject: [PATCH] Revert "Remove malloc(): corrupted top size workaround" This reverts commit ac3dbe0178958cd0e2a1371055fa1befff279fce. --- tools/sheet/index.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/tools/sheet/index.ts b/tools/sheet/index.ts index 9ba4fa41..ec53e7dc 100644 --- a/tools/sheet/index.ts +++ b/tools/sheet/index.ts @@ -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();