@cannbot-plugin/cannbot-dsh-server 1.0.0-alpha.5 → 1.0.0-alpha.6

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.
@@ -338,7 +338,6 @@ async function runInitializationTerminal(spawn, argv, cwd, io) {
338
338
  terminating ??= terminal.terminate();
339
339
  terminating.catch(() => {});
340
340
  };
341
- const timer = setTimeout(stop, 12e5);
342
341
  io.signal.addEventListener("abort", stop, { once: true });
343
342
  if (io.signal.aborted) stop();
344
343
  terminal.output.setEncoding("utf8");
@@ -349,12 +348,11 @@ async function runInitializationTerminal(spawn, argv, cwd, io) {
349
348
  const outcome = await terminal.done;
350
349
  if (terminating) await terminating;
351
350
  io.signal.throwIfAborted();
352
- if (terminating || outcome.exitCode !== 0) throw new Error(terminating ? "初始化超时。" : `初始化退出(${outcome.exitCode ?? outcome.signal})。`);
351
+ if (outcome.exitCode !== 0) throw new Error(`初始化退出(${outcome.exitCode ?? outcome.signal})。`);
353
352
  } finally {
354
353
  io.input = void 0;
355
- clearTimeout(timer);
356
354
  io.signal.removeEventListener("abort", stop);
357
- await terminal.terminate();
355
+ await (terminating ?? terminal.terminate());
358
356
  terminal.output.off("data", output);
359
357
  }
360
358
  }
@@ -398,6 +396,7 @@ var InitializationJobs = class {
398
396
  }
399
397
  };
400
398
  this.jobs.set(job.id, job);
399
+ job.disconnectTimer = setTimeout(() => controller.abort(/* @__PURE__ */ new Error("终端连接已超时,请重新初始化。")), 12e5).unref();
401
400
  initializationIO.run(job.io, async () => {
402
401
  try {
403
402
  controller.signal.throwIfAborted();
@@ -405,8 +404,10 @@ var InitializationJobs = class {
405
404
  job.phase = "ready";
406
405
  } catch (error) {
407
406
  job.phase = "error";
408
- job.message = controller.signal.aborted && !error.recoveryFailed ? "已取消初始化,可以重试。" : String(error.message).slice(-2e3);
407
+ job.message = controller.signal.aborted && !error.recoveryFailed ? controller.signal.reason.message : String(error.message).slice(-2e3);
409
408
  } finally {
409
+ clearTimeout(job.disconnectTimer);
410
+ job.disconnectTimer = void 0;
410
411
  job.touched = Date.now();
411
412
  job.io.input = void 0;
412
413
  }
@@ -416,6 +417,7 @@ var InitializationJobs = class {
416
417
  const job = this.jobs.get(request.jobId);
417
418
  if (!job) throw new Error("初始化任务已过期或服务已重启,请关闭后重试。");
418
419
  job.touched = Date.now();
420
+ job.disconnectTimer?.refresh();
419
421
  if (request.action === "cancel-initialization" && job.phase === "running") job.controller.abort(/* @__PURE__ */ new Error("初始化已取消。"));
420
422
  if (request.action === "initialization-input") {
421
423
  if (job.pending) await job.pending;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cannbot-plugin/cannbot-dsh-server",
3
- "version": "1.0.0-alpha.5",
3
+ "version": "1.0.0-alpha.6",
4
4
  "description": "CANNBot development workbench for a Linux DSH server profile",
5
5
  "type": "module",
6
6
  "license": "SEE LICENSE IN LICENSE",
@@ -90,7 +90,7 @@
90
90
  }
91
91
  },
92
92
  "cannbotEdition": "server",
93
- "cannbotBuildId": "4d59d47fec97f29908511f481e4705d799e93db3935fdaea216db13e26755c97",
93
+ "cannbotBuildId": "b19ba84a08ac9f672f07dd539beb88df6db259578d52574cf79b6c1e9369900d",
94
94
  "os": [
95
95
  "linux"
96
96
  ]