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/index.d.cts CHANGED
@@ -16340,7 +16340,20 @@ type ConnectOptions = {
16340
16340
  schema?: 'auto' | 'refresh' | 'cache';
16341
16341
  /** max cache age for 'auto' (default 24h) */
16342
16342
  maxAgeMs?: number;
16343
+ /**
16344
+ * deadline for the FIRST connect, default 30s. 0 or Infinity waits forever.
16345
+ * A refused TCP connection is a ws CLOSE, not a dead transport, so without a
16346
+ * deadline `connect()` sat in the 2s reconnect loop and never settled: scripts
16347
+ * hung with no error and `comfy-ts serve` wedged the module behind its mutex.
16348
+ * Reconnects AFTER a successful connect are untouched and still retry forever.
16349
+ */
16350
+ timeoutMs?: number;
16343
16351
  };
16352
+ /** the host never came up within ConnectOptions.timeoutMs */
16353
+ declare class ComfyHostUnreachableError extends Error {
16354
+ /** name, not instanceof: the cli bundle and dist/index.js each define this class */
16355
+ readonly name = "ComfyHostUnreachableError";
16356
+ }
16344
16357
  type SchemaUpdateResult = Maybe<{
16345
16358
  type: 'success';
16346
16359
  } | {
@@ -16458,6 +16471,8 @@ declare class ComfyHost<ID extends string = string> {
16458
16471
  * - 'cache': never fetch (throws when no cache exists)
16459
16472
  */
16460
16473
  connect: (p?: ConnectOptions) => Promise<void>;
16474
+ private _connectTimer;
16475
+ private clearConnectTimer;
16461
16476
  /** close the websocket (e.g. to let a script exit) */
16462
16477
  disconnect: () => void;
16463
16478
  private markReady;
@@ -17354,5 +17369,5 @@ declare function exampleImagePath(name: string): string;
17354
17369
  //#region src/cli/tui-env.d.ts
17355
17370
  declare function isTuiActive(): boolean;
17356
17371
  //#endregion
17357
- export { AbsolutePath, type ActiveLora, type ActiveLoraSource, type AnyVar, BaseNode, BaseNodeFactory, BaseNodeInputs, BaseNodeOutputs, type BoundVars, Branded, type CanonicalGroup, type CanonicalInput, type CanonicalLink, type CanonicalNode, type CanonicalOutput, type CanonicalWidgetValues, type CanonicalWorkflow, ChoiceVar, type CodegenOptions, type ComfyApiJson, type ComfyApiNodeJson, ComfyExecution, type ComfyExecutionData, type ComfyExecutionStatus, ComfyHost, ComfyHostAuthError, type ComfyHostData, type ComfyHostID, type ComfyImageName, ComfyManager, ComfyNode, type ComfyNodeId, type ComfyNodeIdMode, type ComfyNodeMetadata, ComfyNodeOutput, type ComfyNodeSchemaJSON, ComfySchema, type ComfySchemaJSON, ComfySdkBase, ComfySdkShape, type ComfyStorage, ComfyTS, type ComfyUnionValue, type ComfyUploadImageResult, ComfyUploader, ComfyVar, ComfyVarBase, ComfyWorkflow, ComfyWorkflowBuilder, type ComfyWorkflowData, type ComfyWorkflowID, type ConnectOptions, ConvertibleImageFormat, DEFAULT_IMAGE_EXTENSIONS, DEFAULT_SIZE_PRESETS, type DefineWorkflowSpec, DefinedWorkflow, Either, EmptyRecord, type ExecutionProgress, type ExecutionSnapshot, Flavor, FloatVar, HTMLContent, ImageVar, ImageVarEmptyError, type ImageVarOpts, IntVar, InvalidPromptError, IsEqual, type LiteGraphJSON, type LoraNameOf, type LoraStrength, type LorasHost, LorasVar, MDContent, Maybe, MediaImage, type MediaImageData, type NodeMode, NodeOf, type ParsedHostBase, PartialOmit, type PluginInstallStatus, type PluginSuggestion, type ProgressReport, type PromptID, type PromptRelated_WsMsg, type PromptValue, PromptVar, type QualifiedNodeKey, RelativePath, type Requirements, ResilientWebSocketClient, Result, ResultFailure, type RunSettings, SaveOptions, SdkForHost, SeedVar, type SizePreset, type SizeValue, SizeVar, Tagged, TextVar, ToggleVar, type VarKind, type VarValues, type VarsSpec, WorkflowConvertError, WorkflowNormalizeError, type WsLike, type WsMessageEvent, type WsMsg, __FAIL, __OK, activeLoras, asAbsolutePath, asHTMLContent, asMDContent, asRelativePath, auto, auto_, codegenSDK, convertFlowToLiteGraphJSON, convertLiteGraphToPrompt, createMemoryStorage, exampleImagePath, getComfyStorage, getLoraKeyword, hostIdToNamespace, isTuiActive, loraTag, normalizeWorkflow, number_Timestamp, parseHostBase, parseWorkflowJson, renderHttpBase, renderWsUrl, resultFailure, resultSuccess, setDefaultComfyStorage, setLoraKeyword, v };
17372
+ export { AbsolutePath, type ActiveLora, type ActiveLoraSource, type AnyVar, BaseNode, BaseNodeFactory, BaseNodeInputs, BaseNodeOutputs, type BoundVars, Branded, type CanonicalGroup, type CanonicalInput, type CanonicalLink, type CanonicalNode, type CanonicalOutput, type CanonicalWidgetValues, type CanonicalWorkflow, ChoiceVar, type CodegenOptions, type ComfyApiJson, type ComfyApiNodeJson, ComfyExecution, type ComfyExecutionData, type ComfyExecutionStatus, ComfyHost, ComfyHostAuthError, type ComfyHostData, type ComfyHostID, ComfyHostUnreachableError, type ComfyImageName, ComfyManager, ComfyNode, type ComfyNodeId, type ComfyNodeIdMode, type ComfyNodeMetadata, ComfyNodeOutput, type ComfyNodeSchemaJSON, ComfySchema, type ComfySchemaJSON, ComfySdkBase, ComfySdkShape, type ComfyStorage, ComfyTS, type ComfyUnionValue, type ComfyUploadImageResult, ComfyUploader, ComfyVar, ComfyVarBase, ComfyWorkflow, ComfyWorkflowBuilder, type ComfyWorkflowData, type ComfyWorkflowID, type ConnectOptions, ConvertibleImageFormat, DEFAULT_IMAGE_EXTENSIONS, DEFAULT_SIZE_PRESETS, type DefineWorkflowSpec, DefinedWorkflow, Either, EmptyRecord, type ExecutionProgress, type ExecutionSnapshot, Flavor, FloatVar, HTMLContent, ImageVar, ImageVarEmptyError, type ImageVarOpts, IntVar, InvalidPromptError, IsEqual, type LiteGraphJSON, type LoraNameOf, type LoraStrength, type LorasHost, LorasVar, MDContent, Maybe, MediaImage, type MediaImageData, type NodeMode, NodeOf, type ParsedHostBase, PartialOmit, type PluginInstallStatus, type PluginSuggestion, type ProgressReport, type PromptID, type PromptRelated_WsMsg, type PromptValue, PromptVar, type QualifiedNodeKey, RelativePath, type Requirements, ResilientWebSocketClient, Result, ResultFailure, type RunSettings, SaveOptions, SdkForHost, SeedVar, type SizePreset, type SizeValue, SizeVar, Tagged, TextVar, ToggleVar, type VarKind, type VarValues, type VarsSpec, WorkflowConvertError, WorkflowNormalizeError, type WsLike, type WsMessageEvent, type WsMsg, __FAIL, __OK, activeLoras, asAbsolutePath, asHTMLContent, asMDContent, asRelativePath, auto, auto_, codegenSDK, convertFlowToLiteGraphJSON, convertLiteGraphToPrompt, createMemoryStorage, exampleImagePath, getComfyStorage, getLoraKeyword, hostIdToNamespace, isTuiActive, loraTag, normalizeWorkflow, number_Timestamp, parseHostBase, parseWorkflowJson, renderHttpBase, renderWsUrl, resultFailure, resultSuccess, setDefaultComfyStorage, setLoraKeyword, v };
17358
17373
  //# sourceMappingURL=index.d.cts.map
package/dist/index.d.ts CHANGED
@@ -16340,7 +16340,20 @@ type ConnectOptions = {
16340
16340
  schema?: 'auto' | 'refresh' | 'cache';
16341
16341
  /** max cache age for 'auto' (default 24h) */
16342
16342
  maxAgeMs?: number;
16343
+ /**
16344
+ * deadline for the FIRST connect, default 30s. 0 or Infinity waits forever.
16345
+ * A refused TCP connection is a ws CLOSE, not a dead transport, so without a
16346
+ * deadline `connect()` sat in the 2s reconnect loop and never settled: scripts
16347
+ * hung with no error and `comfy-ts serve` wedged the module behind its mutex.
16348
+ * Reconnects AFTER a successful connect are untouched and still retry forever.
16349
+ */
16350
+ timeoutMs?: number;
16343
16351
  };
16352
+ /** the host never came up within ConnectOptions.timeoutMs */
16353
+ declare class ComfyHostUnreachableError extends Error {
16354
+ /** name, not instanceof: the cli bundle and dist/index.js each define this class */
16355
+ readonly name = "ComfyHostUnreachableError";
16356
+ }
16344
16357
  type SchemaUpdateResult = Maybe<{
16345
16358
  type: 'success';
16346
16359
  } | {
@@ -16458,6 +16471,8 @@ declare class ComfyHost<ID extends string = string> {
16458
16471
  * - 'cache': never fetch (throws when no cache exists)
16459
16472
  */
16460
16473
  connect: (p?: ConnectOptions) => Promise<void>;
16474
+ private _connectTimer;
16475
+ private clearConnectTimer;
16461
16476
  /** close the websocket (e.g. to let a script exit) */
16462
16477
  disconnect: () => void;
16463
16478
  private markReady;
@@ -17354,5 +17369,5 @@ declare function exampleImagePath(name: string): string;
17354
17369
  //#region src/cli/tui-env.d.ts
17355
17370
  declare function isTuiActive(): boolean;
17356
17371
  //#endregion
17357
- export { AbsolutePath, type ActiveLora, type ActiveLoraSource, type AnyVar, BaseNode, BaseNodeFactory, BaseNodeInputs, BaseNodeOutputs, type BoundVars, Branded, type CanonicalGroup, type CanonicalInput, type CanonicalLink, type CanonicalNode, type CanonicalOutput, type CanonicalWidgetValues, type CanonicalWorkflow, ChoiceVar, type CodegenOptions, type ComfyApiJson, type ComfyApiNodeJson, ComfyExecution, type ComfyExecutionData, type ComfyExecutionStatus, ComfyHost, ComfyHostAuthError, type ComfyHostData, type ComfyHostID, type ComfyImageName, ComfyManager, ComfyNode, type ComfyNodeId, type ComfyNodeIdMode, type ComfyNodeMetadata, ComfyNodeOutput, type ComfyNodeSchemaJSON, ComfySchema, type ComfySchemaJSON, ComfySdkBase, ComfySdkShape, type ComfyStorage, ComfyTS, type ComfyUnionValue, type ComfyUploadImageResult, ComfyUploader, ComfyVar, ComfyVarBase, ComfyWorkflow, ComfyWorkflowBuilder, type ComfyWorkflowData, type ComfyWorkflowID, type ConnectOptions, ConvertibleImageFormat, DEFAULT_IMAGE_EXTENSIONS, DEFAULT_SIZE_PRESETS, type DefineWorkflowSpec, DefinedWorkflow, Either, EmptyRecord, type ExecutionProgress, type ExecutionSnapshot, Flavor, FloatVar, HTMLContent, ImageVar, ImageVarEmptyError, type ImageVarOpts, IntVar, InvalidPromptError, IsEqual, type LiteGraphJSON, type LoraNameOf, type LoraStrength, type LorasHost, LorasVar, MDContent, Maybe, MediaImage, type MediaImageData, type NodeMode, NodeOf, type ParsedHostBase, PartialOmit, type PluginInstallStatus, type PluginSuggestion, type ProgressReport, type PromptID, type PromptRelated_WsMsg, type PromptValue, PromptVar, type QualifiedNodeKey, RelativePath, type Requirements, ResilientWebSocketClient, Result, ResultFailure, type RunSettings, SaveOptions, SdkForHost, SeedVar, type SizePreset, type SizeValue, SizeVar, Tagged, TextVar, ToggleVar, type VarKind, type VarValues, type VarsSpec, WorkflowConvertError, WorkflowNormalizeError, type WsLike, type WsMessageEvent, type WsMsg, __FAIL, __OK, activeLoras, asAbsolutePath, asHTMLContent, asMDContent, asRelativePath, auto, auto_, codegenSDK, convertFlowToLiteGraphJSON, convertLiteGraphToPrompt, createMemoryStorage, exampleImagePath, getComfyStorage, getLoraKeyword, hostIdToNamespace, isTuiActive, loraTag, normalizeWorkflow, number_Timestamp, parseHostBase, parseWorkflowJson, renderHttpBase, renderWsUrl, resultFailure, resultSuccess, setDefaultComfyStorage, setLoraKeyword, v };
17372
+ export { AbsolutePath, type ActiveLora, type ActiveLoraSource, type AnyVar, BaseNode, BaseNodeFactory, BaseNodeInputs, BaseNodeOutputs, type BoundVars, Branded, type CanonicalGroup, type CanonicalInput, type CanonicalLink, type CanonicalNode, type CanonicalOutput, type CanonicalWidgetValues, type CanonicalWorkflow, ChoiceVar, type CodegenOptions, type ComfyApiJson, type ComfyApiNodeJson, ComfyExecution, type ComfyExecutionData, type ComfyExecutionStatus, ComfyHost, ComfyHostAuthError, type ComfyHostData, type ComfyHostID, ComfyHostUnreachableError, type ComfyImageName, ComfyManager, ComfyNode, type ComfyNodeId, type ComfyNodeIdMode, type ComfyNodeMetadata, ComfyNodeOutput, type ComfyNodeSchemaJSON, ComfySchema, type ComfySchemaJSON, ComfySdkBase, ComfySdkShape, type ComfyStorage, ComfyTS, type ComfyUnionValue, type ComfyUploadImageResult, ComfyUploader, ComfyVar, ComfyVarBase, ComfyWorkflow, ComfyWorkflowBuilder, type ComfyWorkflowData, type ComfyWorkflowID, type ConnectOptions, ConvertibleImageFormat, DEFAULT_IMAGE_EXTENSIONS, DEFAULT_SIZE_PRESETS, type DefineWorkflowSpec, DefinedWorkflow, Either, EmptyRecord, type ExecutionProgress, type ExecutionSnapshot, Flavor, FloatVar, HTMLContent, ImageVar, ImageVarEmptyError, type ImageVarOpts, IntVar, InvalidPromptError, IsEqual, type LiteGraphJSON, type LoraNameOf, type LoraStrength, type LorasHost, LorasVar, MDContent, Maybe, MediaImage, type MediaImageData, type NodeMode, NodeOf, type ParsedHostBase, PartialOmit, type PluginInstallStatus, type PluginSuggestion, type ProgressReport, type PromptID, type PromptRelated_WsMsg, type PromptValue, PromptVar, type QualifiedNodeKey, RelativePath, type Requirements, ResilientWebSocketClient, Result, ResultFailure, type RunSettings, SaveOptions, SdkForHost, SeedVar, type SizePreset, type SizeValue, SizeVar, Tagged, TextVar, ToggleVar, type VarKind, type VarValues, type VarsSpec, WorkflowConvertError, WorkflowNormalizeError, type WsLike, type WsMessageEvent, type WsMsg, __FAIL, __OK, activeLoras, asAbsolutePath, asHTMLContent, asMDContent, asRelativePath, auto, auto_, codegenSDK, convertFlowToLiteGraphJSON, convertLiteGraphToPrompt, createMemoryStorage, exampleImagePath, getComfyStorage, getLoraKeyword, hostIdToNamespace, isTuiActive, loraTag, normalizeWorkflow, number_Timestamp, parseHostBase, parseWorkflowJson, renderHttpBase, renderWsUrl, resultFailure, resultSuccess, setDefaultComfyStorage, setLoraKeyword, v };
17358
17373
  //# sourceMappingURL=index.d.ts.map
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.2.0";
113
+ var version = "2.3.0";
114
114
  //#endregion
115
115
  //#region src/litegraph/LiteGraphLinkID.ts
116
116
  const asLiteGraphLinkID = (id) => id;
@@ -4568,6 +4568,14 @@ var DefinedWorkflow = class {
4568
4568
  };
4569
4569
  //#endregion
4570
4570
  //#region src/host/ComfyHost.ts
4571
+ /** the host never came up within ConnectOptions.timeoutMs */
4572
+ var ComfyHostUnreachableError = class extends Error {
4573
+ constructor(..._args) {
4574
+ super(..._args);
4575
+ this.name = "ComfyHostUnreachableError";
4576
+ }
4577
+ };
4578
+ const DEFAULT_CONNECT_TIMEOUT_MS = 3e4;
4571
4579
  /** auth failure with a SPECIFIC meaning (per the Comfy Cloud error table):
4572
4580
  * 401 invalid/missing key · 402 insufficient credits · 429 subscription inactive
4573
4581
  * (or plain rate limiting on non-cloud hosts). The key value never appears here. */
@@ -4717,14 +4725,25 @@ var ComfyHost = class {
4717
4725
  this._readyResolve = res;
4718
4726
  this._readyReject = rej;
4719
4727
  });
4728
+ const timeoutMs = p.timeoutMs ?? DEFAULT_CONNECT_TIMEOUT_MS;
4729
+ if (timeoutMs > 0 && Number.isFinite(timeoutMs)) {
4730
+ this._connectTimer = setTimeout(() => {
4731
+ this.markFailed(new ComfyHostUnreachableError(`host '${this.data.id}' did not come up within ${timeoutMs}ms at ${this.getWSUrl()} — is ComfyUI running there ?`));
4732
+ }, timeoutMs);
4733
+ this._connectTimer.unref?.();
4734
+ }
4720
4735
  this.initWebsocket();
4721
4736
  }
4722
4737
  return this._ready;
4723
4738
  };
4739
+ this._connectTimer = null;
4724
4740
  this.disconnect = () => {
4741
+ this.clearConnectTimer();
4725
4742
  this.ws?.disconnectPermanently();
4726
4743
  this.ws = null;
4727
4744
  this._ready = null;
4745
+ this._readyResolve = null;
4746
+ this._readyReject = null;
4728
4747
  };
4729
4748
  this.ws = null;
4730
4749
  this._sessionResolve = null;
@@ -4869,15 +4888,26 @@ var ComfyHost = class {
4869
4888
  get isConnected() {
4870
4889
  return this.ws?.isOpen ?? false;
4871
4890
  }
4891
+ clearConnectTimer() {
4892
+ if (this._connectTimer != null) clearTimeout(this._connectTimer);
4893
+ this._connectTimer = null;
4894
+ }
4872
4895
  markReady() {
4896
+ this.clearConnectTimer();
4873
4897
  this._readyResolve?.();
4874
4898
  this._readyResolve = null;
4875
4899
  this._readyReject = null;
4876
4900
  }
4877
4901
  markFailed(error) {
4878
- this._readyReject?.(error);
4902
+ this.clearConnectTimer();
4903
+ const reject = this._readyReject;
4904
+ if (reject == null) return;
4879
4905
  this._readyResolve = null;
4880
4906
  this._readyReject = null;
4907
+ this._ready = null;
4908
+ this.ws?.disconnectPermanently();
4909
+ this.ws = null;
4910
+ reject(error);
4881
4911
  }
4882
4912
  async writeSDKToDisk() {
4883
4913
  if (this.data.sdkAutoWrite === false) return;
@@ -5784,6 +5814,6 @@ function isTuiActive() {
5784
5814
  */
5785
5815
  setDefaultComfyStorage(createNodeStorage());
5786
5816
  //#endregion
5787
- export { ChoiceVar, ComfyExecution, ComfyHost, ComfyHostAuthError, ComfyManager, ComfyNode, ComfyNodeOutput, ComfySchema, ComfyTS, ComfyUploader, ComfyVar, ComfyVarBase, ComfyWorkflow, ComfyWorkflowBuilder, DEFAULT_IMAGE_EXTENSIONS, DEFAULT_SIZE_PRESETS, DefinedWorkflow, FloatVar, ImageVar, ImageVarEmptyError, IntVar, InvalidPromptError, LorasVar, MediaImage, PromptVar, ResilientWebSocketClient, SeedVar, SizeVar, TextVar, ToggleVar, WorkflowConvertError, WorkflowNormalizeError, __FAIL, __OK, activeLoras, asAbsolutePath, asHTMLContent, asMDContent, asRelativePath, auto, auto_, codegenSDK, convertFlowToLiteGraphJSON, convertLiteGraphToPrompt, createMemoryStorage, exampleImagePath, getComfyStorage, getLoraKeyword, hostIdToNamespace, isTuiActive, loraTag, normalizeWorkflow, parseHostBase, parseWorkflowJson, renderHttpBase, renderWsUrl, resultFailure, resultSuccess, setDefaultComfyStorage, setLoraKeyword, v };
5817
+ export { ChoiceVar, ComfyExecution, ComfyHost, ComfyHostAuthError, ComfyHostUnreachableError, ComfyManager, ComfyNode, ComfyNodeOutput, ComfySchema, ComfyTS, ComfyUploader, ComfyVar, ComfyVarBase, ComfyWorkflow, ComfyWorkflowBuilder, DEFAULT_IMAGE_EXTENSIONS, DEFAULT_SIZE_PRESETS, DefinedWorkflow, FloatVar, ImageVar, ImageVarEmptyError, IntVar, InvalidPromptError, LorasVar, MediaImage, PromptVar, ResilientWebSocketClient, SeedVar, SizeVar, TextVar, ToggleVar, WorkflowConvertError, WorkflowNormalizeError, __FAIL, __OK, activeLoras, asAbsolutePath, asHTMLContent, asMDContent, asRelativePath, auto, auto_, codegenSDK, convertFlowToLiteGraphJSON, convertLiteGraphToPrompt, createMemoryStorage, exampleImagePath, getComfyStorage, getLoraKeyword, hostIdToNamespace, isTuiActive, loraTag, normalizeWorkflow, parseHostBase, parseWorkflowJson, renderHttpBase, renderWsUrl, resultFailure, resultSuccess, setDefaultComfyStorage, setLoraKeyword, v };
5788
5818
 
5789
5819
  //# sourceMappingURL=index.js.map