comfy-ts 2.4.0 → 2.4.1

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/web.d.ts CHANGED
@@ -15873,6 +15873,14 @@ declare class ResilientWebSocketClient {
15873
15873
  /** transport unrecoverable (no ws package AND no global WebSocket, or ctor threw):
15874
15874
  * reported here ONCE, the client goes permanently closed — never a retry storm */
15875
15875
  onTransportDead?: (error: unknown) => void;
15876
+ /**
15877
+ * the socket closed WITHOUT ever opening: nothing is listening there.
15878
+ * That is a definitive answer, not a blip, so it is reported instead of
15879
+ * retried and the caller decides. The 2s retry loop exists to heal an
15880
+ * ESTABLISHED session; spending it on a refused connect only makes every
15881
+ * waiter sit for the full connect deadline. No callback = retry as before.
15882
+ */
15883
+ onFirstConnectFailed?: (error: unknown) => void;
15876
15884
  };
15877
15885
  private url;
15878
15886
  private currentWS?;
@@ -15893,7 +15901,17 @@ declare class ResilientWebSocketClient {
15893
15901
  /** transport unrecoverable (no ws package AND no global WebSocket, or ctor threw):
15894
15902
  * reported here ONCE, the client goes permanently closed — never a retry storm */
15895
15903
  onTransportDead?: (error: unknown) => void;
15904
+ /**
15905
+ * the socket closed WITHOUT ever opening: nothing is listening there.
15906
+ * That is a definitive answer, not a blip, so it is reported instead of
15907
+ * retried and the caller decides. The 2s retry loop exists to heal an
15908
+ * ESTABLISHED session; spending it on a refused connect only makes every
15909
+ * waiter sit for the full connect deadline. No callback = retry as before.
15910
+ */
15911
+ onFirstConnectFailed?: (error: unknown) => void;
15896
15912
  });
15913
+ /** an established session heals by retrying; a first connect that never opened does not */
15914
+ private hasEverOpened;
15897
15915
  private reconnectTimeout?;
15898
15916
  private permanentlyClosed;
15899
15917
  /** close and stop reconnecting (lets a script exit cleanly) */
package/dist/web.js CHANGED
@@ -101,7 +101,7 @@ function getComfyStorage() {
101
101
  }
102
102
  //#endregion
103
103
  //#region package.json
104
- var version = "2.4.0";
104
+ var version = "2.4.1";
105
105
  //#endregion
106
106
  //#region src/litegraph/LiteGraphLinkID.ts
107
107
  const asLiteGraphLinkID = (id) => id;
@@ -3802,6 +3802,7 @@ var ResilientWebSocketClient = class {
3802
3802
  this.messageBuffer = [];
3803
3803
  this.isOpen = false;
3804
3804
  this.debugMessages = [];
3805
+ this.hasEverOpened = false;
3805
3806
  this.permanentlyClosed = false;
3806
3807
  this.url = options.url();
3807
3808
  this.connect();
@@ -3853,6 +3854,7 @@ var ResilientWebSocketClient = class {
3853
3854
  ws.onopen = () => {
3854
3855
  if (ws !== this.currentWS) return;
3855
3856
  this.addInfo("✅ WebSocket connected to " + this.url);
3857
+ this.hasEverOpened = true;
3856
3858
  this.isOpen = true;
3857
3859
  this.options.onConnectOrReconnect();
3858
3860
  this.flushMessageBuffer();
@@ -3863,6 +3865,11 @@ var ResilientWebSocketClient = class {
3863
3865
  this.options.onClose();
3864
3866
  if (this.permanentlyClosed) return;
3865
3867
  this.addError(`WebSocket closed (reason=${JSON.stringify(event.reason)}, code=${event.code})`);
3868
+ if (!this.hasEverOpened && this.options.onFirstConnectFailed != null) {
3869
+ this.permanentlyClosed = true;
3870
+ this.options.onFirstConnectFailed(/* @__PURE__ */ new Error(`connection refused (code=${event.code}${event.reason === "" ? "" : `, ${event.reason}`})`));
3871
+ return;
3872
+ }
3866
3873
  this.addInfo("⏱️ reconnecting in 2 seconds...");
3867
3874
  this.reconnectTimeout = setTimeout(() => void this.connect(), 2e3);
3868
3875
  };
@@ -5176,6 +5183,7 @@ var ComfyHost = class {
5176
5183
  url: () => this.getWSUrl(),
5177
5184
  headers: () => this.authHeaders(),
5178
5185
  onTransportDead: (e) => this.markFailed(e),
5186
+ onFirstConnectFailed: (e) => this.markFailed(new ComfyHostUnreachableError(`host '${this.data.id}' is not reachable at ${this.getWSUrl()} — ${extractErrorMessage(e)}. Is ComfyUI running there ?`)),
5179
5187
  onClose: () => {
5180
5188
  logInfo(`[👢] WEBSOCKET: closed connection to ComfyUI host ${this.data.id}`);
5181
5189
  }