From 776eda2d4ecd80dbc00ec92426bf940253384879 Mon Sep 17 00:00:00 2001 From: John McLear Date: Fri, 20 Nov 2020 23:33:31 +0000 Subject: [PATCH] import/export: Kill soffice spawned process after 120 seconds (#4499) Due to libreoffice being buggy / hanging on certain pdf imports (even in 7.0.3) we should just kill it so it doesn't consume CPU indefinitely. --- src/node/utils/LibreOffice.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/node/utils/LibreOffice.js b/src/node/utils/LibreOffice.js index dfbee8fa5..39bce5b4d 100644 --- a/src/node/utils/LibreOffice.js +++ b/src/node/utils/LibreOffice.js @@ -89,7 +89,13 @@ function doConvertTask(task, callback) { task.srcFile, '--outdir', tmpDir ]); - + // Soffice/libreoffice is buggy and often hangs. + // To remedy this we kill the spawned process after a while. + setTimeout(function(){ + soffice.stdin.pause(); // required to kill hanging threads + soffice.kill(); + }, 120000); + var stdoutBuffer = ''; // Delegate the processing of stdout to another function