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.
@@ -884,7 +884,7 @@ var ComfySchema = class {
884
884
  };
885
885
  //#endregion
886
886
  //#region package.json
887
- var version = "2.2.0";
887
+ var version = "2.3.0";
888
888
  //#endregion
889
889
  //#region src/litegraph/LiteGraphLinkID.ts
890
890
  const asLiteGraphLinkID = (id) => id;
@@ -3753,6 +3753,14 @@ var ResilientWebSocketClient = class {
3753
3753
  };
3754
3754
  //#endregion
3755
3755
  //#region src/host/ComfyHost.ts
3756
+ /** the host never came up within ConnectOptions.timeoutMs */
3757
+ var ComfyHostUnreachableError = class extends Error {
3758
+ constructor(..._args) {
3759
+ super(..._args);
3760
+ this.name = "ComfyHostUnreachableError";
3761
+ }
3762
+ };
3763
+ const DEFAULT_CONNECT_TIMEOUT_MS = 3e4;
3756
3764
  /** auth failure with a SPECIFIC meaning (per the Comfy Cloud error table):
3757
3765
  * 401 invalid/missing key · 402 insufficient credits · 429 subscription inactive
3758
3766
  * (or plain rate limiting on non-cloud hosts). The key value never appears here. */
@@ -3902,14 +3910,25 @@ var ComfyHost = class {
3902
3910
  this._readyResolve = res;
3903
3911
  this._readyReject = rej;
3904
3912
  });
3913
+ const timeoutMs = p.timeoutMs ?? DEFAULT_CONNECT_TIMEOUT_MS;
3914
+ if (timeoutMs > 0 && Number.isFinite(timeoutMs)) {
3915
+ this._connectTimer = setTimeout(() => {
3916
+ this.markFailed(new ComfyHostUnreachableError(`host '${this.data.id}' did not come up within ${timeoutMs}ms at ${this.getWSUrl()} — is ComfyUI running there ?`));
3917
+ }, timeoutMs);
3918
+ this._connectTimer.unref?.();
3919
+ }
3905
3920
  this.initWebsocket();
3906
3921
  }
3907
3922
  return this._ready;
3908
3923
  };
3924
+ this._connectTimer = null;
3909
3925
  this.disconnect = () => {
3926
+ this.clearConnectTimer();
3910
3927
  this.ws?.disconnectPermanently();
3911
3928
  this.ws = null;
3912
3929
  this._ready = null;
3930
+ this._readyResolve = null;
3931
+ this._readyReject = null;
3913
3932
  };
3914
3933
  this.ws = null;
3915
3934
  this._sessionResolve = null;
@@ -4054,15 +4073,26 @@ var ComfyHost = class {
4054
4073
  get isConnected() {
4055
4074
  return this.ws?.isOpen ?? false;
4056
4075
  }
4076
+ clearConnectTimer() {
4077
+ if (this._connectTimer != null) clearTimeout(this._connectTimer);
4078
+ this._connectTimer = null;
4079
+ }
4057
4080
  markReady() {
4081
+ this.clearConnectTimer();
4058
4082
  this._readyResolve?.();
4059
4083
  this._readyResolve = null;
4060
4084
  this._readyReject = null;
4061
4085
  }
4062
4086
  markFailed(error) {
4063
- this._readyReject?.(error);
4087
+ this.clearConnectTimer();
4088
+ const reject = this._readyReject;
4089
+ if (reject == null) return;
4064
4090
  this._readyResolve = null;
4065
4091
  this._readyReject = null;
4092
+ this._ready = null;
4093
+ this.ws?.disconnectPermanently();
4094
+ this.ws = null;
4095
+ reject(error);
4066
4096
  }
4067
4097
  async writeSDKToDisk() {
4068
4098
  if (this.data.sdkAutoWrite === false) return;
@@ -4900,4 +4930,4 @@ var ComfyTS = class ComfyTS {
4900
4930
  //#endregion
4901
4931
  export { importSharp as a, stripAnsi as i, settingsPathFor as n, ComfySchema as o, readableStringify as r, sha1HexOfString as s, ComfyTS as t };
4902
4932
 
4903
- //# sourceMappingURL=state-CvMt0W1-.js.map
4933
+ //# sourceMappingURL=state-C-OOEcp3.js.map