comfyui-node 1.6.1 → 1.6.3
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/.tsbuildinfo +1 -1
- package/dist/call-wrapper.js +856 -856
- package/dist/index.d.ts +7 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -1
- package/dist/index.js.map +1 -1
- package/dist/multipool/client-registry.d.ts +32 -11
- package/dist/multipool/client-registry.d.ts.map +1 -1
- package/dist/multipool/client-registry.js +135 -8
- package/dist/multipool/client-registry.js.map +1 -1
- package/dist/multipool/helpers.d.ts +5 -0
- package/dist/multipool/helpers.d.ts.map +1 -0
- package/dist/multipool/helpers.js +53 -0
- package/dist/multipool/helpers.js.map +1 -0
- package/dist/multipool/index.d.ts +2 -1
- package/dist/multipool/index.d.ts.map +1 -1
- package/dist/multipool/index.js +2 -1
- package/dist/multipool/index.js.map +1 -1
- package/dist/multipool/interfaces.d.ts +25 -0
- package/dist/multipool/interfaces.d.ts.map +1 -1
- package/dist/multipool/job-profiler.d.ts +128 -0
- package/dist/multipool/job-profiler.d.ts.map +1 -0
- package/dist/multipool/job-profiler.js +222 -0
- package/dist/multipool/job-profiler.js.map +1 -0
- package/dist/multipool/job-queue-processor.d.ts +27 -11
- package/dist/multipool/job-queue-processor.d.ts.map +1 -1
- package/dist/multipool/job-queue-processor.js +196 -9
- package/dist/multipool/job-queue-processor.js.map +1 -1
- package/dist/multipool/job-state-registry.d.ts +67 -0
- package/dist/multipool/job-state-registry.d.ts.map +1 -0
- package/dist/multipool/job-state-registry.js +283 -0
- package/dist/multipool/job-state-registry.js.map +1 -0
- package/dist/multipool/logger.d.ts +30 -0
- package/dist/multipool/logger.d.ts.map +1 -0
- package/dist/multipool/logger.js +75 -0
- package/dist/multipool/logger.js.map +1 -0
- package/dist/multipool/multi-workflow-pool.d.ts +86 -7
- package/dist/multipool/multi-workflow-pool.d.ts.map +1 -1
- package/dist/multipool/multi-workflow-pool.js +365 -13
- package/dist/multipool/multi-workflow-pool.js.map +1 -1
- package/dist/multipool/pool-event-manager.d.ts +10 -10
- package/dist/multipool/tests/client-registry-api-demo.d.ts +7 -0
- package/dist/multipool/tests/client-registry-api-demo.d.ts.map +1 -0
- package/dist/multipool/tests/client-registry-api-demo.js +136 -0
- package/dist/multipool/tests/client-registry-api-demo.js.map +1 -0
- package/dist/multipool/tests/client-registry.spec.d.ts +2 -0
- package/dist/multipool/tests/client-registry.spec.d.ts.map +1 -0
- package/dist/multipool/tests/client-registry.spec.js +191 -0
- package/dist/multipool/tests/client-registry.spec.js.map +1 -0
- package/dist/multipool/tests/error-classification-tests.d.ts +2 -0
- package/dist/multipool/tests/error-classification-tests.d.ts.map +1 -0
- package/dist/multipool/tests/error-classification-tests.js +374 -0
- package/dist/multipool/tests/error-classification-tests.js.map +1 -0
- package/dist/multipool/tests/event-forwarding-demo.d.ts +7 -0
- package/dist/multipool/tests/event-forwarding-demo.d.ts.map +1 -0
- package/dist/multipool/tests/event-forwarding-demo.js +88 -0
- package/dist/multipool/tests/event-forwarding-demo.js.map +1 -0
- package/dist/multipool/tests/helpers.spec.d.ts +2 -0
- package/dist/multipool/tests/helpers.spec.d.ts.map +1 -0
- package/dist/multipool/tests/helpers.spec.js +100 -0
- package/dist/multipool/tests/helpers.spec.js.map +1 -0
- package/dist/multipool/tests/job-queue-processor.spec.d.ts +2 -0
- package/dist/multipool/tests/job-queue-processor.spec.d.ts.map +1 -0
- package/dist/multipool/tests/job-queue-processor.spec.js +89 -0
- package/dist/multipool/tests/job-queue-processor.spec.js.map +1 -0
- package/dist/multipool/tests/job-state-registry.d.ts +16 -16
- package/dist/multipool/tests/job-state-registry.js +23 -23
- package/dist/multipool/tests/job-state-registry.spec.d.ts +2 -0
- package/dist/multipool/tests/job-state-registry.spec.d.ts.map +1 -0
- package/dist/multipool/tests/job-state-registry.spec.js +143 -0
- package/dist/multipool/tests/job-state-registry.spec.js.map +1 -0
- package/dist/multipool/tests/multipool-basic.d.ts +11 -1
- package/dist/multipool/tests/multipool-basic.d.ts.map +1 -1
- package/dist/multipool/tests/multipool-basic.js +140 -2
- package/dist/multipool/tests/multipool-basic.js.map +1 -1
- package/dist/multipool/tests/profiling-demo.d.ts +7 -0
- package/dist/multipool/tests/profiling-demo.d.ts.map +1 -0
- package/dist/multipool/tests/profiling-demo.js +88 -0
- package/dist/multipool/tests/profiling-demo.js.map +1 -0
- package/dist/multipool/tests/prompt-generator.d.ts +10 -0
- package/dist/multipool/tests/prompt-generator.d.ts.map +1 -0
- package/dist/multipool/tests/prompt-generator.js +26 -0
- package/dist/multipool/tests/prompt-generator.js.map +1 -0
- package/dist/multipool/tests/test-helpers.d.ts +4 -0
- package/dist/multipool/tests/test-helpers.d.ts.map +1 -0
- package/dist/multipool/tests/test-helpers.js +10 -0
- package/dist/multipool/tests/test-helpers.js.map +1 -0
- package/dist/multipool/tests/two-stage-edit-simulation.d.ts +32 -0
- package/dist/multipool/tests/two-stage-edit-simulation.d.ts.map +1 -0
- package/dist/multipool/tests/two-stage-edit-simulation.js +299 -0
- package/dist/multipool/tests/two-stage-edit-simulation.js.map +1 -0
- package/dist/multipool/workflow.d.ts +178 -173
- package/dist/multipool/workflow.d.ts.map +1 -1
- package/dist/multipool/workflow.js +333 -271
- package/dist/multipool/workflow.js.map +1 -1
- package/dist/pool/SmartPool.d.ts +143 -143
- package/dist/pool/SmartPool.js +676 -676
- package/dist/pool/SmartPoolV2.d.ts +119 -119
- package/dist/pool/SmartPoolV2.js +586 -586
- package/dist/pool/WorkflowPool.d.ts +202 -202
- package/dist/pool/WorkflowPool.d.ts.map +1 -1
- package/dist/pool/WorkflowPool.js +845 -840
- package/dist/pool/WorkflowPool.js.map +1 -1
- package/dist/pool/client/ClientManager.d.ts +86 -86
- package/dist/pool/client/ClientManager.js +215 -215
- package/dist/pool/index.d.ts +9 -11
- package/dist/pool/index.d.ts.map +1 -1
- package/dist/pool/index.js +3 -5
- package/dist/pool/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,203 +1,203 @@
|
|
|
1
|
-
import { TypedEventTarget } from "../typed-event-target.js";
|
|
2
|
-
import type { ComfyApi } from "../client.js";
|
|
3
|
-
import type { QueueAdapter, QueueStats } from "./queue/QueueAdapter.js";
|
|
4
|
-
import type { FailoverStrategy } from "./failover/Strategy.js";
|
|
5
|
-
import type { JobRecord, WorkflowInput, WorkflowJobOptions, JobId } from "./types/job.js";
|
|
6
|
-
import type { WorkflowPoolEventMap } from "./types/events.js";
|
|
7
|
-
import type { WorkflowAffinity } from "./types/affinity.js";
|
|
8
|
-
/**
|
|
9
|
-
* Configuration options for WorkflowPool.
|
|
10
|
-
*/
|
|
11
|
-
export interface WorkflowPoolOpts {
|
|
12
|
-
/**
|
|
13
|
-
* An array of workflow affinity rules to establish a default mapping
|
|
14
|
-
* between workflows and specific clients.
|
|
15
|
-
*
|
|
16
|
-
* @example
|
|
17
|
-
* ```ts
|
|
18
|
-
* const pool = new WorkflowPool(clients, {
|
|
19
|
-
* workflowAffinities: [
|
|
20
|
-
* { workflowHash: "hash1", preferredClientIds: ["client-a"] },
|
|
21
|
-
* { workflowHash: "hash2", excludeClientIds: ["client-b"] },
|
|
22
|
-
* ]
|
|
23
|
-
* });
|
|
24
|
-
* ```
|
|
25
|
-
*/
|
|
26
|
-
workflowAffinities?: WorkflowAffinity[];
|
|
27
|
-
/**
|
|
28
|
-
* Queue adapter for managing job queue operations.
|
|
29
|
-
*
|
|
30
|
-
* @default MemoryQueueAdapter (in-memory queue)
|
|
31
|
-
* @example
|
|
32
|
-
* ```ts
|
|
33
|
-
* import { WorkflowPool, MemoryQueueAdapter } from 'comfyui-node';
|
|
34
|
-
* const pool = new WorkflowPool(clients, {
|
|
35
|
-
* queueAdapter: new MemoryQueueAdapter()
|
|
36
|
-
* });
|
|
37
|
-
* ```
|
|
38
|
-
*/
|
|
39
|
-
queueAdapter?: QueueAdapter;
|
|
40
|
-
/**
|
|
41
|
-
* Failover strategy for handling client failures and workflow routing.
|
|
42
|
-
*
|
|
43
|
-
* @default SmartFailoverStrategy (exponential backoff with workflow-specific cooldowns)
|
|
44
|
-
* @example
|
|
45
|
-
* ```ts
|
|
46
|
-
* import { WorkflowPool, SmartFailoverStrategy } from 'comfyui-node';
|
|
47
|
-
* const pool = new WorkflowPool(clients, {
|
|
48
|
-
* failoverStrategy: new SmartFailoverStrategy()
|
|
49
|
-
* });
|
|
50
|
-
* ```
|
|
51
|
-
*/
|
|
52
|
-
failoverStrategy?: FailoverStrategy;
|
|
53
|
-
/**
|
|
54
|
-
* Base retry backoff delay in milliseconds for failed jobs.
|
|
55
|
-
* Actual delay may be adjusted by the failover strategy.
|
|
56
|
-
*
|
|
57
|
-
* @default 1000 (1 second)
|
|
58
|
-
*/
|
|
59
|
-
retryBackoffMs?: number;
|
|
60
|
-
/**
|
|
61
|
-
* Timeout in milliseconds for execution to start after job is queued.
|
|
62
|
-
*
|
|
63
|
-
* If a server gets stuck before emitting the `execution_start` event, the job
|
|
64
|
-
* will be failed and retried on another server after this timeout.
|
|
65
|
-
*
|
|
66
|
-
* This prevents jobs from being lost when a server accepts a prompt but fails
|
|
67
|
-
* to begin execution (e.g., GPU hang, process crash, deadlock).
|
|
68
|
-
*
|
|
69
|
-
* Set to `0` to disable timeout (not recommended for production).
|
|
70
|
-
*
|
|
71
|
-
* @default 5000 (5 seconds)
|
|
72
|
-
* @example
|
|
73
|
-
* ```ts
|
|
74
|
-
* const pool = new WorkflowPool(clients, {
|
|
75
|
-
* executionStartTimeoutMs: 10000 // 10 seconds
|
|
76
|
-
* });
|
|
77
|
-
* ```
|
|
78
|
-
* @since 1.5.0
|
|
79
|
-
*/
|
|
80
|
-
executionStartTimeoutMs?: number;
|
|
81
|
-
/**
|
|
82
|
-
* Timeout in milliseconds for individual node execution.
|
|
83
|
-
*
|
|
84
|
-
* If a node takes longer than this timeout to execute (time between `executing` events),
|
|
85
|
-
* the job will be failed and retried on another server.
|
|
86
|
-
*
|
|
87
|
-
* This is critical for:
|
|
88
|
-
* - Model loading on slow disks (can take 60+ seconds on first load)
|
|
89
|
-
* - Heavy diffusion steps on slower GPUs
|
|
90
|
-
* - VAE decode operations on large images
|
|
91
|
-
* - Custom nodes with long processing times
|
|
92
|
-
*
|
|
93
|
-
* The timeout is per-node, not total execution time. Each node gets the full timeout duration.
|
|
94
|
-
*
|
|
95
|
-
* Set to `0` to disable timeout (not recommended for production).
|
|
96
|
-
*
|
|
97
|
-
* @default 300000 (5 minutes)
|
|
98
|
-
* @example
|
|
99
|
-
* ```ts
|
|
100
|
-
* const pool = new WorkflowPool(clients, {
|
|
101
|
-
* nodeExecutionTimeoutMs: 600000 // 10 minutes for slow model loading
|
|
102
|
-
* });
|
|
103
|
-
* ```
|
|
104
|
-
* @remarks
|
|
105
|
-
* - Timeout resets when a new node starts executing
|
|
106
|
-
* - Progress events (e.g., KSampler steps) reset the timeout
|
|
107
|
-
* - First generation with model loading often needs longer timeout
|
|
108
|
-
* - Cached nodes complete instantly and don't trigger timeout
|
|
109
|
-
* @since 1.5.0
|
|
110
|
-
*/
|
|
111
|
-
nodeExecutionTimeoutMs?: number;
|
|
112
|
-
/**
|
|
113
|
-
* Interval in milliseconds for health check pings to keep WebSocket connections alive.
|
|
114
|
-
*
|
|
115
|
-
* Health checks prevent idle connection timeouts by periodically pinging inactive clients
|
|
116
|
-
* with lightweight `getQueue()` calls. This maintains stable connections when the pool
|
|
117
|
-
* has no active jobs, avoiding false disconnection alerts.
|
|
118
|
-
*
|
|
119
|
-
* Set to `0` to disable health checks (not recommended for production).
|
|
120
|
-
*
|
|
121
|
-
* @default 30000 (30 seconds)
|
|
122
|
-
* @example
|
|
123
|
-
* ```ts
|
|
124
|
-
* const pool = new WorkflowPool(clients, {
|
|
125
|
-
* healthCheckIntervalMs: 30000 // ping every 30 seconds
|
|
126
|
-
* });
|
|
127
|
-
* ```
|
|
128
|
-
* @remarks
|
|
129
|
-
* - Only pings idle (non-busy) clients to avoid interference with active jobs
|
|
130
|
-
* - Recommended for long-running services or when using persistent connections
|
|
131
|
-
* - Lower values increase network traffic but detect issues faster
|
|
132
|
-
* - Higher values reduce overhead but may miss connection issues sooner
|
|
133
|
-
* @since 1.4.1
|
|
134
|
-
*/
|
|
135
|
-
healthCheckIntervalMs?: number;
|
|
136
|
-
/**
|
|
137
|
-
* Enable automatic profiling of workflow execution.
|
|
138
|
-
*
|
|
139
|
-
* When enabled, captures detailed per-node execution metrics including:
|
|
140
|
-
* - Node execution timing (start, end, duration)
|
|
141
|
-
* - Progress events for long-running nodes
|
|
142
|
-
* - Cached vs executed nodes
|
|
143
|
-
* - Execution order and dependencies
|
|
144
|
-
*
|
|
145
|
-
* Profile stats are attached to `JobRecord.profileStats` and included
|
|
146
|
-
* in `job:completed` event details.
|
|
147
|
-
*
|
|
148
|
-
* @default false
|
|
149
|
-
* @example
|
|
150
|
-
* ```ts
|
|
151
|
-
* const pool = new WorkflowPool(clients, {
|
|
152
|
-
* enableProfiling: true
|
|
153
|
-
* });
|
|
154
|
-
*
|
|
155
|
-
* pool.on('job:completed', (event) => {
|
|
156
|
-
* const stats = event.detail.job.profileStats;
|
|
157
|
-
* console.log(`Total: ${stats.totalDuration}ms`);
|
|
158
|
-
* console.log(`Slowest nodes:`, stats.summary.slowestNodes);
|
|
159
|
-
* });
|
|
160
|
-
* ```
|
|
161
|
-
* @since 1.5.0
|
|
162
|
-
*/
|
|
163
|
-
enableProfiling?: boolean;
|
|
164
|
-
}
|
|
165
|
-
export declare class WorkflowPool extends TypedEventTarget<WorkflowPoolEventMap> {
|
|
166
|
-
private queue;
|
|
167
|
-
private strategy;
|
|
168
|
-
private clientManager;
|
|
169
|
-
private opts;
|
|
170
|
-
private jobStore;
|
|
171
|
-
private jobFailureAnalysis;
|
|
172
|
-
private affinities;
|
|
173
|
-
private initPromise;
|
|
174
|
-
private processing;
|
|
175
|
-
private processQueued;
|
|
176
|
-
private activeJobs;
|
|
177
|
-
private readonly queueDebug;
|
|
178
|
-
private debugLog;
|
|
179
|
-
constructor(clients: ComfyApi[], opts?: WorkflowPoolOpts);
|
|
180
|
-
ready(): Promise<void>;
|
|
181
|
-
setAffinity(affinity: WorkflowAffinity): void;
|
|
182
|
-
removeAffinity(workflowHash: string): boolean;
|
|
183
|
-
getAffinities(): WorkflowAffinity[];
|
|
184
|
-
enqueue(workflowInput: WorkflowInput, options?: WorkflowJobOptions): Promise<JobId>;
|
|
185
|
-
getJob(jobId: string): JobRecord | undefined;
|
|
186
|
-
cancel(jobId: string): Promise<boolean>;
|
|
187
|
-
shutdown(): Promise<void>;
|
|
188
|
-
getQueueStats(): Promise<QueueStats>;
|
|
189
|
-
private normalizeWorkflow;
|
|
190
|
-
private generateJobId;
|
|
191
|
-
private static fallbackId;
|
|
192
|
-
private scheduleProcess;
|
|
193
|
-
private applyAutoSeed;
|
|
194
|
-
private rememberJobFailure;
|
|
195
|
-
private clearJobFailures;
|
|
196
|
-
private collectFailureReasons;
|
|
197
|
-
private addPermanentExclusion;
|
|
198
|
-
private hasRetryPath;
|
|
199
|
-
private createWorkflowNotSupportedError;
|
|
200
|
-
private processQueue;
|
|
201
|
-
private runJob;
|
|
202
|
-
}
|
|
1
|
+
import { TypedEventTarget } from "../typed-event-target.js";
|
|
2
|
+
import type { ComfyApi } from "../client.js";
|
|
3
|
+
import type { QueueAdapter, QueueStats } from "./queue/QueueAdapter.js";
|
|
4
|
+
import type { FailoverStrategy } from "./failover/Strategy.js";
|
|
5
|
+
import type { JobRecord, WorkflowInput, WorkflowJobOptions, JobId } from "./types/job.js";
|
|
6
|
+
import type { WorkflowPoolEventMap } from "./types/events.js";
|
|
7
|
+
import type { WorkflowAffinity } from "./types/affinity.js";
|
|
8
|
+
/**
|
|
9
|
+
* Configuration options for WorkflowPool.
|
|
10
|
+
*/
|
|
11
|
+
export interface WorkflowPoolOpts {
|
|
12
|
+
/**
|
|
13
|
+
* An array of workflow affinity rules to establish a default mapping
|
|
14
|
+
* between workflows and specific clients.
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* ```ts
|
|
18
|
+
* const pool = new WorkflowPool(clients, {
|
|
19
|
+
* workflowAffinities: [
|
|
20
|
+
* { workflowHash: "hash1", preferredClientIds: ["client-a"] },
|
|
21
|
+
* { workflowHash: "hash2", excludeClientIds: ["client-b"] },
|
|
22
|
+
* ]
|
|
23
|
+
* });
|
|
24
|
+
* ```
|
|
25
|
+
*/
|
|
26
|
+
workflowAffinities?: WorkflowAffinity[];
|
|
27
|
+
/**
|
|
28
|
+
* Queue adapter for managing job queue operations.
|
|
29
|
+
*
|
|
30
|
+
* @default MemoryQueueAdapter (in-memory queue)
|
|
31
|
+
* @example
|
|
32
|
+
* ```ts
|
|
33
|
+
* import { WorkflowPool, MemoryQueueAdapter } from 'comfyui-node';
|
|
34
|
+
* const pool = new WorkflowPool(clients, {
|
|
35
|
+
* queueAdapter: new MemoryQueueAdapter()
|
|
36
|
+
* });
|
|
37
|
+
* ```
|
|
38
|
+
*/
|
|
39
|
+
queueAdapter?: QueueAdapter;
|
|
40
|
+
/**
|
|
41
|
+
* Failover strategy for handling client failures and workflow routing.
|
|
42
|
+
*
|
|
43
|
+
* @default SmartFailoverStrategy (exponential backoff with workflow-specific cooldowns)
|
|
44
|
+
* @example
|
|
45
|
+
* ```ts
|
|
46
|
+
* import { WorkflowPool, SmartFailoverStrategy } from 'comfyui-node';
|
|
47
|
+
* const pool = new WorkflowPool(clients, {
|
|
48
|
+
* failoverStrategy: new SmartFailoverStrategy()
|
|
49
|
+
* });
|
|
50
|
+
* ```
|
|
51
|
+
*/
|
|
52
|
+
failoverStrategy?: FailoverStrategy;
|
|
53
|
+
/**
|
|
54
|
+
* Base retry backoff delay in milliseconds for failed jobs.
|
|
55
|
+
* Actual delay may be adjusted by the failover strategy.
|
|
56
|
+
*
|
|
57
|
+
* @default 1000 (1 second)
|
|
58
|
+
*/
|
|
59
|
+
retryBackoffMs?: number;
|
|
60
|
+
/**
|
|
61
|
+
* Timeout in milliseconds for execution to start after job is queued.
|
|
62
|
+
*
|
|
63
|
+
* If a server gets stuck before emitting the `execution_start` event, the job
|
|
64
|
+
* will be failed and retried on another server after this timeout.
|
|
65
|
+
*
|
|
66
|
+
* This prevents jobs from being lost when a server accepts a prompt but fails
|
|
67
|
+
* to begin execution (e.g., GPU hang, process crash, deadlock).
|
|
68
|
+
*
|
|
69
|
+
* Set to `0` to disable timeout (not recommended for production).
|
|
70
|
+
*
|
|
71
|
+
* @default 5000 (5 seconds)
|
|
72
|
+
* @example
|
|
73
|
+
* ```ts
|
|
74
|
+
* const pool = new WorkflowPool(clients, {
|
|
75
|
+
* executionStartTimeoutMs: 10000 // 10 seconds
|
|
76
|
+
* });
|
|
77
|
+
* ```
|
|
78
|
+
* @since 1.5.0
|
|
79
|
+
*/
|
|
80
|
+
executionStartTimeoutMs?: number;
|
|
81
|
+
/**
|
|
82
|
+
* Timeout in milliseconds for individual node execution.
|
|
83
|
+
*
|
|
84
|
+
* If a node takes longer than this timeout to execute (time between `executing` events),
|
|
85
|
+
* the job will be failed and retried on another server.
|
|
86
|
+
*
|
|
87
|
+
* This is critical for:
|
|
88
|
+
* - Model loading on slow disks (can take 60+ seconds on first load)
|
|
89
|
+
* - Heavy diffusion steps on slower GPUs
|
|
90
|
+
* - VAE decode operations on large images
|
|
91
|
+
* - Custom nodes with long processing times
|
|
92
|
+
*
|
|
93
|
+
* The timeout is per-node, not total execution time. Each node gets the full timeout duration.
|
|
94
|
+
*
|
|
95
|
+
* Set to `0` to disable timeout (not recommended for production).
|
|
96
|
+
*
|
|
97
|
+
* @default 300000 (5 minutes)
|
|
98
|
+
* @example
|
|
99
|
+
* ```ts
|
|
100
|
+
* const pool = new WorkflowPool(clients, {
|
|
101
|
+
* nodeExecutionTimeoutMs: 600000 // 10 minutes for slow model loading
|
|
102
|
+
* });
|
|
103
|
+
* ```
|
|
104
|
+
* @remarks
|
|
105
|
+
* - Timeout resets when a new node starts executing
|
|
106
|
+
* - Progress events (e.g., KSampler steps) reset the timeout
|
|
107
|
+
* - First generation with model loading often needs longer timeout
|
|
108
|
+
* - Cached nodes complete instantly and don't trigger timeout
|
|
109
|
+
* @since 1.5.0
|
|
110
|
+
*/
|
|
111
|
+
nodeExecutionTimeoutMs?: number;
|
|
112
|
+
/**
|
|
113
|
+
* Interval in milliseconds for health check pings to keep WebSocket connections alive.
|
|
114
|
+
*
|
|
115
|
+
* Health checks prevent idle connection timeouts by periodically pinging inactive clients
|
|
116
|
+
* with lightweight `getQueue()` calls. This maintains stable connections when the pool
|
|
117
|
+
* has no active jobs, avoiding false disconnection alerts.
|
|
118
|
+
*
|
|
119
|
+
* Set to `0` to disable health checks (not recommended for production).
|
|
120
|
+
*
|
|
121
|
+
* @default 30000 (30 seconds)
|
|
122
|
+
* @example
|
|
123
|
+
* ```ts
|
|
124
|
+
* const pool = new WorkflowPool(clients, {
|
|
125
|
+
* healthCheckIntervalMs: 30000 // ping every 30 seconds
|
|
126
|
+
* });
|
|
127
|
+
* ```
|
|
128
|
+
* @remarks
|
|
129
|
+
* - Only pings idle (non-busy) clients to avoid interference with active jobs
|
|
130
|
+
* - Recommended for long-running services or when using persistent connections
|
|
131
|
+
* - Lower values increase network traffic but detect issues faster
|
|
132
|
+
* - Higher values reduce overhead but may miss connection issues sooner
|
|
133
|
+
* @since 1.4.1
|
|
134
|
+
*/
|
|
135
|
+
healthCheckIntervalMs?: number;
|
|
136
|
+
/**
|
|
137
|
+
* Enable automatic profiling of workflow execution.
|
|
138
|
+
*
|
|
139
|
+
* When enabled, captures detailed per-node execution metrics including:
|
|
140
|
+
* - Node execution timing (start, end, duration)
|
|
141
|
+
* - Progress events for long-running nodes
|
|
142
|
+
* - Cached vs executed nodes
|
|
143
|
+
* - Execution order and dependencies
|
|
144
|
+
*
|
|
145
|
+
* Profile stats are attached to `JobRecord.profileStats` and included
|
|
146
|
+
* in `job:completed` event details.
|
|
147
|
+
*
|
|
148
|
+
* @default false
|
|
149
|
+
* @example
|
|
150
|
+
* ```ts
|
|
151
|
+
* const pool = new WorkflowPool(clients, {
|
|
152
|
+
* enableProfiling: true
|
|
153
|
+
* });
|
|
154
|
+
*
|
|
155
|
+
* pool.on('job:completed', (event) => {
|
|
156
|
+
* const stats = event.detail.job.profileStats;
|
|
157
|
+
* console.log(`Total: ${stats.totalDuration}ms`);
|
|
158
|
+
* console.log(`Slowest nodes:`, stats.summary.slowestNodes);
|
|
159
|
+
* });
|
|
160
|
+
* ```
|
|
161
|
+
* @since 1.5.0
|
|
162
|
+
*/
|
|
163
|
+
enableProfiling?: boolean;
|
|
164
|
+
}
|
|
165
|
+
export declare class WorkflowPool extends TypedEventTarget<WorkflowPoolEventMap> {
|
|
166
|
+
private queue;
|
|
167
|
+
private strategy;
|
|
168
|
+
private clientManager;
|
|
169
|
+
private opts;
|
|
170
|
+
private jobStore;
|
|
171
|
+
private jobFailureAnalysis;
|
|
172
|
+
private affinities;
|
|
173
|
+
private initPromise;
|
|
174
|
+
private processing;
|
|
175
|
+
private processQueued;
|
|
176
|
+
private activeJobs;
|
|
177
|
+
private readonly queueDebug;
|
|
178
|
+
private debugLog;
|
|
179
|
+
constructor(clients: ComfyApi[], opts?: WorkflowPoolOpts);
|
|
180
|
+
ready(): Promise<void>;
|
|
181
|
+
setAffinity(affinity: WorkflowAffinity): void;
|
|
182
|
+
removeAffinity(workflowHash: string): boolean;
|
|
183
|
+
getAffinities(): WorkflowAffinity[];
|
|
184
|
+
enqueue(workflowInput: WorkflowInput, options?: WorkflowJobOptions): Promise<JobId>;
|
|
185
|
+
getJob(jobId: string): JobRecord | undefined;
|
|
186
|
+
cancel(jobId: string): Promise<boolean>;
|
|
187
|
+
shutdown(): Promise<void>;
|
|
188
|
+
getQueueStats(): Promise<QueueStats>;
|
|
189
|
+
private normalizeWorkflow;
|
|
190
|
+
private generateJobId;
|
|
191
|
+
private static fallbackId;
|
|
192
|
+
private scheduleProcess;
|
|
193
|
+
private applyAutoSeed;
|
|
194
|
+
private rememberJobFailure;
|
|
195
|
+
private clearJobFailures;
|
|
196
|
+
private collectFailureReasons;
|
|
197
|
+
private addPermanentExclusion;
|
|
198
|
+
private hasRetryPath;
|
|
199
|
+
private createWorkflowNotSupportedError;
|
|
200
|
+
private processQueue;
|
|
201
|
+
private runJob;
|
|
202
|
+
}
|
|
203
203
|
//# sourceMappingURL=WorkflowPool.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"WorkflowPool.d.ts","sourceRoot":"","sources":["../../src/pool/WorkflowPool.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAC5D,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAK7C,OAAO,KAAK,EAAE,YAAY,EAAoB,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAC1F,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAK/D,OAAO,KAAK,EAAE,SAAS,EAAE,aAAa,EAAE,kBAAkB,EAAsB,KAAK,EAAE,MAAM,gBAAgB,CAAC;AAC9G,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AAK9D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAE5D;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B;;;;;;;;;;;;;OAaG;IACH,kBAAkB,CAAC,EAAE,gBAAgB,EAAE,CAAC;IACxC;;;;;;;;;;;OAWG;IACH,YAAY,CAAC,EAAE,YAAY,CAAC;IAE5B;;;;;;;;;;;OAWG;IACH,gBAAgB,CAAC,EAAE,gBAAgB,CAAC;IAEpC;;;;;OAKG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;IAExB;;;;;;;;;;;;;;;;;;;OAmBG;IACH,uBAAuB,CAAC,EAAE,MAAM,CAAC;IAEjC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA6BG;IACH,sBAAsB,CAAC,EAAE,MAAM,CAAC;IAEhC;;;;;;;;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