comfy-ts 2.2.0 → 2.3.0

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/dist/cli.js CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { o as ComfySchema, r as readableStringify, t as ComfyTS } from "./state-CvMt0W1-.js";
2
+ import { o as ComfySchema, r as readableStringify, t as ComfyTS } from "./state-C-OOEcp3.js";
3
3
  import { spawnSync } from "node:child_process";
4
4
  import { fileURLToPath } from "node:url";
5
5
  import { existsSync, mkdirSync, readFileSync, readdirSync, writeFileSync } from "node:fs";
@@ -164,10 +164,10 @@ async function main() {
164
164
  console.error(`[comfy-ts ${cmd}] bun not found (${res.error.message}) — continuing under node: the examples packaged in node_modules cannot load here, and your own .cflow.ts modules rely on node's type stripping`);
165
165
  }
166
166
  if (cmd === "serve") {
167
- const { runServe } = await import("./run-serve-C1oo5ilG.js");
167
+ const { runServe } = await import("./run-serve-CfzOH-AR.js");
168
168
  return runServe(rest);
169
169
  }
170
- const { runTui } = await import("./run-tui-CuVst-nc.js");
170
+ const { runTui } = await import("./run-tui-_LD0DoGe.js");
171
171
  return runTui(rest);
172
172
  }
173
173
  console.log(HELP);
package/dist/index.cjs CHANGED
@@ -134,7 +134,7 @@ function createNodeStorage() {
134
134
  }
135
135
  //#endregion
136
136
  //#region package.json
137
- var version = "2.2.0";
137
+ var version = "2.3.0";
138
138
  //#endregion
139
139
  //#region src/litegraph/LiteGraphLinkID.ts
140
140
  const asLiteGraphLinkID = (id) => id;
@@ -4595,6 +4595,14 @@ var DefinedWorkflow = class {
4595
4595
  };
4596
4596
  //#endregion
4597
4597
  //#region src/host/ComfyHost.ts
4598
+ /** the host never came up within ConnectOptions.timeoutMs */
4599
+ var ComfyHostUnreachableError = class extends Error {
4600
+ constructor(..._args) {
4601
+ super(..._args);
4602
+ this.name = "ComfyHostUnreachableError";
4603
+ }
4604
+ };
4605
+ const DEFAULT_CONNECT_TIMEOUT_MS = 3e4;
4598
4606
  /** auth failure with a SPECIFIC meaning (per the Comfy Cloud error table):
4599
4607
  * 401 invalid/missing key · 402 insufficient credits · 429 subscription inactive
4600
4608
  * (or plain rate limiting on non-cloud hosts). The key value never appears here. */
@@ -4744,14 +4752,25 @@ var ComfyHost = class {
4744
4752
  this._readyResolve = res;
4745
4753
  this._readyReject = rej;
4746
4754
  });
4755
+ const timeoutMs = p.timeoutMs ?? DEFAULT_CONNECT_TIMEOUT_MS;
4756
+ if (timeoutMs > 0 && Number.isFinite(timeoutMs)) {
4757
+ this._connectTimer = setTimeout(() => {
4758
+ this.markFailed(new ComfyHostUnreachableError(`host '${this.data.id}' did not come up within ${timeoutMs}ms at ${this.getWSUrl()} — is ComfyUI running there ?`));
4759
+ }, timeoutMs);
4760
+ this._connectTimer.unref?.();
4761
+ }
4747
4762
  this.initWebsocket();
4748
4763
  }
4749
4764
  return this._ready;
4750
4765
  };
4766
+ this._connectTimer = null;
4751
4767
  this.disconnect = () => {
4768
+ this.clearConnectTimer();
4752
4769
  this.ws?.disconnectPermanently();
4753
4770
  this.ws = null;
4754
4771
  this._ready = null;
4772
+ this._readyResolve = null;
4773
+ this._readyReject = null;
4755
4774
  };
4756
4775
  this.ws = null;
4757
4776
  this._sessionResolve = null;
@@ -4896,15 +4915,26 @@ var ComfyHost = class {
4896
4915
  get isConnected() {
4897
4916
  return this.ws?.isOpen ?? false;
4898
4917
  }
4918
+ clearConnectTimer() {
4919
+ if (this._connectTimer != null) clearTimeout(this._connectTimer);
4920
+ this._connectTimer = null;
4921
+ }
4899
4922
  markReady() {
4923
+ this.clearConnectTimer();
4900
4924
  this._readyResolve?.();
4901
4925
  this._readyResolve = null;
4902
4926
  this._readyReject = null;
4903
4927
  }
4904
4928
  markFailed(error) {
4905
- this._readyReject?.(error);
4929
+ this.clearConnectTimer();
4930
+ const reject = this._readyReject;
4931
+ if (reject == null) return;
4906
4932
  this._readyResolve = null;
4907
4933
  this._readyReject = null;
4934
+ this._ready = null;
4935
+ this.ws?.disconnectPermanently();
4936
+ this.ws = null;
4937
+ reject(error);
4908
4938
  }
4909
4939
  async writeSDKToDisk() {
4910
4940
  if (this.data.sdkAutoWrite === false) return;
@@ -5815,6 +5845,7 @@ exports.ChoiceVar = ChoiceVar;
5815
5845
  exports.ComfyExecution = ComfyExecution;
5816
5846
  exports.ComfyHost = ComfyHost;
5817
5847
  exports.ComfyHostAuthError = ComfyHostAuthError;
5848
+ exports.ComfyHostUnreachableError = ComfyHostUnreachableError;
5818
5849
  exports.ComfyManager = ComfyManager;
5819
5850
  exports.ComfyNode = ComfyNode;
5820
5851
  exports.ComfyNodeOutput = ComfyNodeOutput;