From 305bfadb5f61671ef19bafc25114633a71a3e7dd Mon Sep 17 00:00:00 2001 From: kirillgroshkov Date: Thu, 18 Jul 2024 17:43:30 +0200 Subject: [PATCH] feat: runScript to do `pDelay` before exiting To let async operations complete --- src/script/runScript.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/script/runScript.ts b/src/script/runScript.ts index 1965768..e6be779 100644 --- a/src/script/runScript.ts +++ b/src/script/runScript.ts @@ -1,4 +1,4 @@ -import { setGlobalStringifyFunction } from '@naturalcycles/js-lib' +import { pDelay, setGlobalStringifyFunction } from '@naturalcycles/js-lib' import type { CommonLogger } from '@naturalcycles/js-lib' import { inspectStringifyFn } from '../string/inspect' @@ -60,6 +60,8 @@ export function runScript(fn: (...args: any[]) => any, opt: RunScriptOptions = { try { await fn() + await pDelay() // to ensure all async operations are completed + if (DEBUG_RUN_SCRIPT) logger.log(`runScript promise resolved`) if (!noExit) {