@naturalcycles/nodejs-lib 15.101.0 → 15.102.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,5 @@
1
1
  import os from 'node:os';
2
- import { pDelay } from '@naturalcycles/js-lib/promise/pDelay.js';
2
+ import { AsyncManager } from '@naturalcycles/js-lib';
3
3
  import { setGlobalStringifyFunction } from '@naturalcycles/js-lib/string/stringify.js';
4
4
  import { dimGrey } from '../colors/colors.js';
5
5
  import { loadEnvFileIfExists } from '../node.util.js';
@@ -45,9 +45,10 @@ export function runScript(fn, opt = {}) {
45
45
  void (async () => {
46
46
  try {
47
47
  await fn();
48
- await pDelay(); // to ensure all async operations are completed
49
48
  if (DEBUG_RUN_SCRIPT)
50
49
  logger.log(`runScript promise resolved`);
50
+ // to ensure all async operations are completed (with a timeout)
51
+ await AsyncManager.allDone(600_000);
51
52
  if (!noExit) {
52
53
  setImmediate(() => process.exit(0));
53
54
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@naturalcycles/nodejs-lib",
3
3
  "type": "module",
4
- "version": "15.101.0",
4
+ "version": "15.102.0",
5
5
  "dependencies": {
6
6
  "@naturalcycles/js-lib": "^15",
7
7
  "@standard-schema/spec": "^1",
@@ -1,6 +1,6 @@
1
1
  import os from 'node:os'
2
+ import { AsyncManager } from '@naturalcycles/js-lib'
2
3
  import type { CommonLogger } from '@naturalcycles/js-lib/log'
3
- import { pDelay } from '@naturalcycles/js-lib/promise/pDelay.js'
4
4
  import { setGlobalStringifyFunction } from '@naturalcycles/js-lib/string/stringify.js'
5
5
  import type { AnyObject } from '@naturalcycles/js-lib/types'
6
6
  import { dimGrey } from '../colors/colors.js'
@@ -76,10 +76,11 @@ export function runScript(fn: (...args: any[]) => any, opt: RunScriptOptions = {
76
76
  try {
77
77
  await fn()
78
78
 
79
- await pDelay() // to ensure all async operations are completed
80
-
81
79
  if (DEBUG_RUN_SCRIPT) logger.log(`runScript promise resolved`)
82
80
 
81
+ // to ensure all async operations are completed (with a timeout)
82
+ await AsyncManager.allDone(600_000)
83
+
83
84
  if (!noExit) {
84
85
  setImmediate(() => process.exit(0))
85
86
  }