Skip to content

Commit

Permalink
feat: runScript to do pDelay before exiting
Browse files Browse the repository at this point in the history
To let async operations complete
  • Loading branch information
kirillgroshkov committed Jul 18, 2024
1 parent 1c2537e commit 305bfad
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/script/runScript.ts
Original file line number Diff line number Diff line change
@@ -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'

Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit 305bfad

Please sign in to comment.