From b2a12e167b813a9f61efec3ce17c779437164e28 Mon Sep 17 00:00:00 2001 From: Robert Aboukhalil Date: Tue, 17 Aug 2021 20:28:54 -0700 Subject: [PATCH] Flush stdout/stderr to fix issues with bcftools query not returning any output --- src/worker.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/worker.js b/src/worker.js index 407ced5..059d3e6 100644 --- a/src/worker.js +++ b/src/worker.js @@ -248,6 +248,13 @@ const aioli = { // Run command. Stdout/Stderr will be saved to "tool.stdout"/"tool.stderr" (see "print" and "printErr" above) tool.module.callMain(args); + // Flush stdout/stderr to make sure we got everything. Otherwise, if use a command like + // `bcftools query -f "%ALT" variants.bcf`, it won't output anything until the next + // invocation of that command! + try { + tool.module.FS.close( tool.module.FS.streams[1] ); + tool.module.FS.close( tool.module.FS.streams[2] ); + } catch (error) {} // Re-open stdout/stderr (fix error "error closing standard output: -1") tool.module.FS.streams[1] = tool.module.FS.open("/dev/stdout", "w"); tool.module.FS.streams[2] = tool.module.FS.open("/dev/stderr", "w");