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/index.d.cts 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/index.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/index.js CHANGED
@@ -110,7 +110,7 @@ function createNodeStorage() {
110
110
  }
111
111
  //#endregion
112
112
  //#region package.json
113
- var version = "2.4.0";
113
+ var version = "2.4.1";
114
114
  //#endregion
115
115
  //#region src/litegraph/LiteGraphLinkID.ts
116
116
  const asLiteGraphLinkID = (id) => id;
@@ -3811,6 +3811,7 @@ var ResilientWebSocketClient = class {
3811
3811
  this.messageBuffer = [];
3812
3812
  this.isOpen = false;
3813
3813
  this.debugMessages = [];
3814
+ this.hasEverOpened = false;
3814
3815
  this.permanentlyClosed = false;
3815
3816
  this.url = options.url();
3816
3817
  this.connect();
@@ -3862,6 +3863,7 @@ var ResilientWebSocketClient = class {
3862
3863
  ws.onopen = () => {
3863
3864
  if (ws !== this.currentWS) return;
3864
3865
  this.addInfo("✅ WebSocket connected to " + this.url);
3866
+ this.hasEverOpened = true;
3865
3867
  this.isOpen = true;
3866
3868
  this.options.onConnectOrReconnect();
3867
3869
  this.flushMessageBuffer();
@@ -3872,6 +3874,11 @@ var ResilientWebSocketClient = class {
3872
3874
  this.options.onClose();
3873
3875
  if (this.permanentlyClosed) return;
3874
3876
  this.addError(`WebSocket closed (reason=${JSON.stringify(event.reason)}, code=${event.code})`);
3877
+ if (!this.hasEverOpened && this.options.onFirstConnectFailed != null) {
3878
+ this.permanentlyClosed = true;
3879
+ this.options.onFirstConnectFailed(/* @__PURE__ */ new Error(`connection refused (code=${event.code}${event.reason === "" ? "" : `, ${event.reason}`})`));
3880
+ return;
3881
+ }
3875
3882
  this.addInfo("⏱️ reconnecting in 2 seconds...");
3876
3883
  this.reconnectTimeout = setTimeout(() => void this.connect(), 2e3);
3877
3884
  };
@@ -5185,6 +5192,7 @@ var ComfyHost = class {
5185
5192
  url: () => this.getWSUrl(),
5186
5193
  headers: () => this.authHeaders(),
5187
5194
  onTransportDead: (e) => this.markFailed(e),
5195
+ onFirstConnectFailed: (e) => this.markFailed(new ComfyHostUnreachableError(`host '${this.data.id}' is not reachable at ${this.getWSUrl()} — ${extractErrorMessage(e)}. Is ComfyUI running there ?`)),
5188
5196
  onClose: () => {
5189
5197
  logInfo(`[👢] WEBSOCKET: closed connection to ComfyUI host ${this.data.id}`);
5190
5198
  }