wok-server 0.4.8 → 0.4.9

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,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.scheduleWithFixedDelay = void 0;
4
+ const log_1 = require("../log");
4
5
  const validation_1 = require("../validation");
5
6
  const task_1 = require("./task");
6
7
  /**
@@ -28,6 +29,9 @@ function exec(delay, task, controller) {
28
29
  await (0, task_1.execTask)(task);
29
30
  // 下次执行
30
31
  setTimeout(() => exec(delay, task, controller), delay * 1000);
32
+ })
33
+ .catch(e => {
34
+ (0, log_1.getLogger)().error(`EXEC TASK ERROR: ${task.name}`, e);
31
35
  })
32
36
  .catch(console.error);
33
37
  }
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.scheduleWithFixedRate = void 0;
4
+ const log_1 = require("../log");
4
5
  const validation_1 = require("../validation");
5
6
  const task_1 = require("./task");
6
7
  /**
@@ -32,6 +33,9 @@ function exec(fixedDelay, task, controller) {
32
33
  delay = 0;
33
34
  }
34
35
  setTimeout(() => exec(fixedDelay, task, controller), delay);
36
+ })
37
+ .catch(e => {
38
+ (0, log_1.getLogger)().error(`EXEC TASK ERROR: ${task.name}`, e);
35
39
  })
36
40
  .catch(console.error);
37
41
  }
package/dist/task/task.js CHANGED
@@ -29,13 +29,13 @@ async function execTask(task) {
29
29
  catch (e) {
30
30
  (0, log_1.getLogger)().error(`TASK ERROR: ${task.name}`, e);
31
31
  }
32
- const end = new Date().getTime();
32
+ const end = Date.now();
33
33
  const cost = end - start;
34
34
  if (cost > 1000 * 60 * 5) {
35
35
  (0, log_1.getLogger)().warn(`Task "${task.name}" takes too long ,cost ${cost}ms`);
36
36
  }
37
37
  else {
38
- (0, log_1.getLogger)().debug(`Task "${task.name}" has finished, taking a total of 388 milliseconds.`);
38
+ (0, log_1.getLogger)().debug(`Task "${task.name}" has finished, taking a total of ${cost} milliseconds.`);
39
39
  }
40
40
  return { start, cost, end };
41
41
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wok-server",
3
- "version": "0.4.8",
3
+ "version": "0.4.9",
4
4
  "packageManager": "pnpm@8.9.0",
5
5
  "description": "一个基于 NodeJs 和 TypeScript 的后端框架,轻量级、克制、简洁。A lightweight, restrained, and concise backend framework based on Node.js and TypeScript.",
6
6
  "scripts": {