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/cli.js +2 -2
- package/dist/index.cjs +9 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +18 -0
- package/dist/index.d.ts +18 -0
- package/dist/index.js +9 -1
- package/dist/index.js.map +1 -1
- package/dist/{run-tui-cawSJuuh.js → run-tui-8si-rVW0.js} +2 -2
- package/dist/{run-tui-cawSJuuh.js.map → run-tui-8si-rVW0.js.map} +1 -1
- package/dist/{state-BbKuSDCV.js → state-C0ARiFFM.js} +10 -2
- package/dist/{state-BbKuSDCV.js.map → state-C0ARiFFM.js.map} +1 -1
- package/dist/web.d.ts +18 -0
- package/dist/web.js +9 -1
- package/dist/web.js.map +1 -1
- package/package.json +1 -1
- package/src/host/ComfyHost.ts +9 -0
- package/src/host/ResilientWebsocket.ts +20 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "comfy-ts",
|
|
3
|
-
"version": "2.4.
|
|
3
|
+
"version": "2.4.1",
|
|
4
4
|
"description": "The complete TypeScript toolkit for ComfyUI and generative AI. Fully type-safe SDK with autocomplete on every node, companion CLI, TUI, agentic docs, and 50+ examples. Design, run and deploy creative pipelines for image, video, audio, 3d and text on any ComfyUI, local, cloud or hosted.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"comfyui",
|
package/src/host/ComfyHost.ts
CHANGED
|
@@ -554,6 +554,15 @@ export class ComfyHost<ID extends string = string> {
|
|
|
554
554
|
// remap X-API-Key to ?token= inside the ws client
|
|
555
555
|
headers: () => this.authHeaders(),
|
|
556
556
|
onTransportDead: (e): void => this.markFailed(e),
|
|
557
|
+
// nothing listening: answer NOW instead of making every caller wait out
|
|
558
|
+
// the deadline. markFailed resets _ready, so the next connect() retries
|
|
559
|
+
// and a host that comes back is reachable again
|
|
560
|
+
onFirstConnectFailed: (e): void =>
|
|
561
|
+
this.markFailed(
|
|
562
|
+
new ComfyHostUnreachableError(
|
|
563
|
+
`host '${this.data.id}' is not reachable at ${this.getWSUrl()} — ${extractErrorMessage(e)}. Is ComfyUI running there ?`,
|
|
564
|
+
),
|
|
565
|
+
),
|
|
557
566
|
onClose: (): void => {
|
|
558
567
|
logInfo(`[👢] WEBSOCKET: closed connection to ComfyUI host ${this.data.id}`)
|
|
559
568
|
},
|
|
@@ -84,12 +84,23 @@ export class ResilientWebSocketClient {
|
|
|
84
84
|
/** transport unrecoverable (no ws package AND no global WebSocket, or ctor threw):
|
|
85
85
|
* reported here ONCE, the client goes permanently closed — never a retry storm */
|
|
86
86
|
onTransportDead?: (error: unknown) => void
|
|
87
|
+
/**
|
|
88
|
+
* the socket closed WITHOUT ever opening: nothing is listening there.
|
|
89
|
+
* That is a definitive answer, not a blip, so it is reported instead of
|
|
90
|
+
* retried and the caller decides. The 2s retry loop exists to heal an
|
|
91
|
+
* ESTABLISHED session; spending it on a refused connect only makes every
|
|
92
|
+
* waiter sit for the full connect deadline. No callback = retry as before.
|
|
93
|
+
*/
|
|
94
|
+
onFirstConnectFailed?: (error: unknown) => void
|
|
87
95
|
},
|
|
88
96
|
) {
|
|
89
97
|
this.url = options.url()
|
|
90
98
|
void this.connect()
|
|
91
99
|
}
|
|
92
100
|
|
|
101
|
+
/** an established session heals by retrying; a first connect that never opened does not */
|
|
102
|
+
private hasEverOpened: boolean = false
|
|
103
|
+
|
|
93
104
|
private reconnectTimeout?: Maybe<ReturnType<typeof setTimeout>>
|
|
94
105
|
private permanentlyClosed: boolean = false
|
|
95
106
|
|
|
@@ -156,6 +167,7 @@ export class ResilientWebSocketClient {
|
|
|
156
167
|
ws.onopen = (): void => {
|
|
157
168
|
if (ws !== this.currentWS) return
|
|
158
169
|
this.addInfo('✅ WebSocket connected to ' + this.url)
|
|
170
|
+
this.hasEverOpened = true
|
|
159
171
|
this.isOpen = true
|
|
160
172
|
this.options.onConnectOrReconnect()
|
|
161
173
|
this.flushMessageBuffer()
|
|
@@ -167,6 +179,14 @@ export class ResilientWebSocketClient {
|
|
|
167
179
|
this.options.onClose()
|
|
168
180
|
if (this.permanentlyClosed) return
|
|
169
181
|
this.addError(`WebSocket closed (reason=${JSON.stringify(event.reason)}, code=${event.code})`)
|
|
182
|
+
// never opened = nothing is listening: report, do not retry (see the option)
|
|
183
|
+
if (!this.hasEverOpened && this.options.onFirstConnectFailed != null) {
|
|
184
|
+
this.permanentlyClosed = true
|
|
185
|
+
this.options.onFirstConnectFailed(
|
|
186
|
+
new Error(`connection refused (code=${event.code}${event.reason === '' ? '' : `, ${event.reason}`})`),
|
|
187
|
+
)
|
|
188
|
+
return
|
|
189
|
+
}
|
|
170
190
|
this.addInfo('⏱️ reconnecting in 2 seconds...')
|
|
171
191
|
this.reconnectTimeout = setTimeout(() => void this.connect(), 2000)
|
|
172
192
|
}
|