@kne/fastify-task 0.1.11 → 0.1.12

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.
@@ -57,12 +57,12 @@ module.exports = fp(async (fastify, options) => {
57
57
  pollCount++;
58
58
  if (pollCount > maxPollTimes) {
59
59
  clearInterval(timer);
60
- reject(`轮询超时(${maxPollTimes}次),任务未完成`);
60
+ reject(new Error(`轮询超时(${maxPollTimes}次),任务未完成`));
61
61
  }
62
62
  const { result, data, message } = Object.assign({}, await callback());
63
63
  if (result === 'failed') {
64
64
  clearInterval(timer);
65
- reject(`任务处理失败:${message}`);
65
+ reject(new Error(`任务处理失败:${message}`));
66
66
  }
67
67
  if (result === 'success') {
68
68
  clearInterval(timer);
@@ -95,14 +95,14 @@ module.exports = fp(async (fastify, options) => {
95
95
  .catch(e => {
96
96
  return task.update({
97
97
  status: 'failed',
98
- error: e.stack,
98
+ error: (e.stack || '').replaceAll(process.cwd(), '/server'),
99
99
  completedAt: new Date()
100
100
  });
101
101
  });
102
102
  } catch (e) {
103
103
  await task.update({
104
104
  status: 'failed',
105
- error: e.stack,
105
+ error: (e.stack || '').replaceAll(process.cwd(), '/server'),
106
106
  completedAt: new Date()
107
107
  });
108
108
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kne/fastify-task",
3
- "version": "0.1.11",
3
+ "version": "0.1.12",
4
4
  "description": "用于编排任务,追踪任务执行状态,结果",
5
5
  "main": "index.js",
6
6
  "scripts": {