@coana-tech/cli 14.12.115 → 14.12.116

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.
package/cli.mjs CHANGED
@@ -234982,6 +234982,8 @@ var SocketLogServer = class {
234982
234982
  writeStream;
234983
234983
  writeQueue = [];
234984
234984
  isWriting = false;
234985
+ isClosing = false;
234986
+ onDrainCallback = null;
234985
234987
  clients = /* @__PURE__ */ new Map();
234986
234988
  constructor(options) {
234987
234989
  this.socketPath = options.socketPath;
@@ -235040,6 +235042,9 @@ var SocketLogServer = class {
235040
235042
  return message2.type === "handshake";
235041
235043
  }
235042
235044
  writeLog(log2) {
235045
+ if (this.isClosing) {
235046
+ return;
235047
+ }
235043
235048
  const label = log2.label ?? log2.context;
235044
235049
  const formattedLog = `${log2.timestamp} ${label} ${log2.level}: ${log2.message}
235045
235050
  `;
@@ -235052,6 +235057,11 @@ var SocketLogServer = class {
235052
235057
  }
235053
235058
  processWriteQueue() {
235054
235059
  if (this.isWriting || this.writeQueue.length === 0) {
235060
+ if (!this.isWriting && this.writeQueue.length === 0 && this.onDrainCallback) {
235061
+ const callback = this.onDrainCallback;
235062
+ this.onDrainCallback = null;
235063
+ callback();
235064
+ }
235055
235065
  return;
235056
235066
  }
235057
235067
  this.isWriting = true;
@@ -235071,11 +235081,37 @@ var SocketLogServer = class {
235071
235081
  this.onLogReceived(log2);
235072
235082
  }
235073
235083
  }
235084
+ async waitForQueueDrain(timeoutMs = 2e4) {
235085
+ return new Promise((resolve45) => {
235086
+ if (!this.isWriting && this.writeQueue.length === 0) {
235087
+ resolve45();
235088
+ return;
235089
+ }
235090
+ let resolved = false;
235091
+ const timeoutId = setTimeout(() => {
235092
+ if (!resolved) {
235093
+ resolved = true;
235094
+ this.onDrainCallback = null;
235095
+ console.warn(`Log write queue drain timeout after ${timeoutMs}ms, proceeding with close`);
235096
+ resolve45();
235097
+ }
235098
+ }, timeoutMs);
235099
+ this.onDrainCallback = () => {
235100
+ if (!resolved) {
235101
+ resolved = true;
235102
+ clearTimeout(timeoutId);
235103
+ resolve45();
235104
+ }
235105
+ };
235106
+ });
235107
+ }
235074
235108
  async close() {
235075
235109
  for (const client of this.clients.values()) {
235076
235110
  client.socket.destroy();
235077
235111
  }
235078
235112
  this.clients.clear();
235113
+ this.isClosing = true;
235114
+ await this.waitForQueueDrain();
235079
235115
  return new Promise((resolve45, reject) => {
235080
235116
  this.server.close((serverError) => {
235081
235117
  this.writeStream.end(() => {
@@ -250908,7 +250944,7 @@ async function onlineScan(dependencyTree, apiKey, timeout) {
250908
250944
  }
250909
250945
 
250910
250946
  // dist/version.js
250911
- var version3 = "14.12.115";
250947
+ var version3 = "14.12.116";
250912
250948
 
250913
250949
  // dist/cli-core.js
250914
250950
  var { mapValues, omit, partition, pick } = import_lodash15.default;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@coana-tech/cli",
3
- "version": "14.12.115",
3
+ "version": "14.12.116",
4
4
  "description": "Coana CLI",
5
5
  "type": "module",
6
6
  "bin": {