From dd221689e158770a4ba3c426c3d0f2267a21d5d3 Mon Sep 17 00:00:00 2001 From: Janne Saukkio Date: Thu, 29 Feb 2024 15:09:19 +0200 Subject: [PATCH] Asynchronously wait for the browser to close before exiting the process --- decktape.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/decktape.js b/decktape.js index 68a9ac7..225195b 100755 --- a/decktape.js +++ b/decktape.js @@ -303,12 +303,14 @@ process.on('unhandledRejection', error => { .then(async context => { await writePdf(options.filename, pdf); console.log(chalk.green(`\nPrinted ${chalk.bold('%s')} slides`), context.exportedSlides); - browser.close(); + // Wait for the browser to close before exiting the process + await browser.close(); process.exit(); })) - .catch(error => { + .catch(async error => { console.log(chalk.red('\n%s'), error); - browser.close(); + // Wait for the browser to close before exiting the process + await browser.close(); process.exit(1); }); })();