@tiflis-io/tiflis-code-workstation 0.3.14 → 0.3.18

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.
Files changed (2) hide show
  1. package/dist/main.js +25 -6
  2. package/package.json +1 -1
package/dist/main.js CHANGED
@@ -1606,6 +1606,9 @@ var TunnelClient = class {
1606
1606
  this.handleRegistrationTimeout();
1607
1607
  }
1608
1608
  }, CONNECTION_TIMING.REGISTRATION_TIMEOUT_MS);
1609
+ if (this.registrationTimeout.unref) {
1610
+ this.registrationTimeout.unref();
1611
+ }
1609
1612
  }
1610
1613
  /**
1611
1614
  * Handles registration timeout.
@@ -1729,6 +1732,9 @@ var TunnelClient = class {
1729
1732
  this.sendToTunnel(ping);
1730
1733
  }
1731
1734
  }, CONNECTION_TIMING.PING_INTERVAL_MS);
1735
+ if (this.pingInterval.unref) {
1736
+ this.pingInterval.unref();
1737
+ }
1732
1738
  }
1733
1739
  /**
1734
1740
  * Schedules a reconnection attempt.
@@ -1749,6 +1755,9 @@ var TunnelClient = class {
1749
1755
  this.scheduleReconnect();
1750
1756
  });
1751
1757
  }, delay);
1758
+ if (this.reconnectTimeout.unref) {
1759
+ this.reconnectTimeout.unref();
1760
+ }
1752
1761
  }
1753
1762
  /**
1754
1763
  * Flushes buffered messages after reconnection.
@@ -2466,7 +2475,7 @@ var Session = class {
2466
2475
  this._workspacePath = props.workspacePath;
2467
2476
  this._workingDir = props.workingDir;
2468
2477
  this._status = "active";
2469
- this._createdAt = /* @__PURE__ */ new Date();
2478
+ this._createdAt = props.createdAt ?? /* @__PURE__ */ new Date();
2470
2479
  this._lastActivityAt = /* @__PURE__ */ new Date();
2471
2480
  }
2472
2481
  get id() {
@@ -11328,7 +11337,7 @@ async function bootstrap() {
11328
11337
  } catch (error) {
11329
11338
  logger.error({ error }, "Failed to connect to tunnel (will retry)");
11330
11339
  }
11331
- const SHUTDOWN_TIMEOUT_MS = 1e4;
11340
+ const SHUTDOWN_TIMEOUT_MS = 5e3;
11332
11341
  let isShuttingDown = false;
11333
11342
  const shutdown = async (signal) => {
11334
11343
  if (isShuttingDown) {
@@ -11349,7 +11358,7 @@ async function bootstrap() {
11349
11358
  logger.info("Terminating all sessions...");
11350
11359
  const terminatePromise = sessionManager.terminateAll();
11351
11360
  const sessionTimeoutPromise = new Promise((_, reject) => {
11352
- setTimeout(() => reject(new Error("Session termination timeout")), 5e3);
11361
+ setTimeout(() => reject(new Error("Session termination timeout")), 2e3);
11353
11362
  });
11354
11363
  try {
11355
11364
  await Promise.race([terminatePromise, sessionTimeoutPromise]);
@@ -11360,7 +11369,7 @@ async function bootstrap() {
11360
11369
  logger.info("Closing HTTP server...");
11361
11370
  const closePromise = app.close();
11362
11371
  const closeTimeoutPromise = new Promise((_, reject) => {
11363
- setTimeout(() => reject(new Error("HTTP server close timeout")), 2e3);
11372
+ setTimeout(() => reject(new Error("HTTP server close timeout")), 1e3);
11364
11373
  });
11365
11374
  try {
11366
11375
  await Promise.race([closePromise, closeTimeoutPromise]);
@@ -11378,8 +11387,18 @@ async function bootstrap() {
11378
11387
  process.exit(1);
11379
11388
  }
11380
11389
  };
11381
- process.on("SIGTERM", () => void shutdown("SIGTERM"));
11382
- process.on("SIGINT", () => void shutdown("SIGINT"));
11390
+ let signalCount = 0;
11391
+ const handleSignal = (signal) => {
11392
+ signalCount++;
11393
+ if (signalCount === 1) {
11394
+ void shutdown(signal);
11395
+ } else {
11396
+ logger.warn({ signal, count: signalCount }, "Force exit on repeated signal");
11397
+ process.exit(1);
11398
+ }
11399
+ };
11400
+ process.on("SIGTERM", () => handleSignal("SIGTERM"));
11401
+ process.on("SIGINT", () => handleSignal("SIGINT"));
11383
11402
  process.on("unhandledRejection", (reason, promise) => {
11384
11403
  logger.error({ reason, promise }, "Unhandled rejection");
11385
11404
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tiflis-io/tiflis-code-workstation",
3
- "version": "0.3.14",
3
+ "version": "0.3.18",
4
4
  "description": "Workstation server for tiflis-code - manages agent sessions and terminal access",
5
5
  "author": "Roman Barinov <rbarinov@gmail.com>",
6
6
  "license": "FSL-1.1-NC",