comfyui-node 1.6.3 → 1.6.5
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/README.md +121 -9
- package/dist/.tsbuildinfo +1 -1
- package/dist/call-wrapper.d.ts.map +1 -1
- package/dist/call-wrapper.js +859 -856
- package/dist/call-wrapper.js.map +1 -1
- package/dist/client.d.ts +27 -0
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +87 -6
- package/dist/client.js.map +1 -1
- package/dist/index.d.ts +6 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/multipool/client-registry.d.ts +23 -32
- package/dist/multipool/client-registry.d.ts.map +1 -1
- package/dist/multipool/client-registry.js +1 -1
- package/dist/multipool/client-registry.js.map +1 -1
- package/dist/multipool/interfaces.d.ts +106 -0
- package/dist/multipool/interfaces.d.ts.map +1 -1
- package/dist/multipool/job-profiler.d.ts +64 -127
- package/dist/multipool/job-profiler.d.ts.map +1 -1
- package/dist/multipool/job-profiler.js +221 -221
- package/dist/multipool/job-profiler.js.map +1 -1
- package/dist/multipool/job-queue-processor.d.ts +23 -27
- package/dist/multipool/job-queue-processor.d.ts.map +1 -1
- package/dist/multipool/job-queue-processor.js +196 -196
- package/dist/multipool/job-queue-processor.js.map +1 -1
- package/dist/multipool/job-state-registry.d.ts +42 -66
- package/dist/multipool/job-state-registry.d.ts.map +1 -1
- package/dist/multipool/job-state-registry.js.map +1 -1
- package/dist/multipool/multi-workflow-pool.d.ts +2 -3
- package/dist/multipool/multi-workflow-pool.d.ts.map +1 -1
- package/dist/multipool/multi-workflow-pool.js +61 -30
- package/dist/multipool/multi-workflow-pool.js.map +1 -1
- package/dist/multipool/pool-event-manager.d.ts +10 -10
- package/dist/multipool/pool-event-manager.d.ts.map +1 -1
- package/dist/multipool/workflow.d.ts +178 -178
- package/dist/multipool/workflow.d.ts.map +1 -1
- package/dist/multipool/workflow.js +333 -333
- package/dist/pool/WorkflowPool.d.ts.map +1 -1
- package/dist/pool/WorkflowPool.js +855 -845
- package/dist/pool/WorkflowPool.js.map +1 -1
- package/dist/pool/client/ClientManager.js +215 -215
- package/dist/pool/index.js +3 -3
- package/dist/pool/types/job.d.ts +15 -0
- package/dist/pool/types/job.d.ts.map +1 -1
- package/dist/types/event.d.ts +17 -1
- package/dist/types/event.d.ts.map +1 -1
- package/dist/utils/model-loading.d.ts +158 -0
- package/dist/utils/model-loading.d.ts.map +1 -0
- package/dist/utils/model-loading.js +273 -0
- package/dist/utils/model-loading.js.map +1 -0
- package/package.json +9 -5
package/README.md
CHANGED
|
@@ -136,12 +136,64 @@ Hash-based routing intelligently handles failures at the workflow level (not cli
|
|
|
136
136
|
|
|
137
137
|
See [Hash-Based Routing Guide](./docs/hash-routing-guide.md) for details and demos.
|
|
138
138
|
|
|
139
|
-
|
|
139
|
+
### Advanced: `MultiWorkflowPool` for Heterogeneous Clusters
|
|
140
140
|
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
-
|
|
144
|
-
|
|
141
|
+
For complex use cases involving a heterogeneous cluster of workers (e.g., some with SDXL models, others for video generation), `MultiWorkflowPool` provides fine-grained control over job routing based on workflow requirements.
|
|
142
|
+
|
|
143
|
+
It uses an event-driven architecture to manage clients with specific **workflow affinities**, ensuring that jobs are only sent to nodes capable of processing them.
|
|
144
|
+
|
|
145
|
+
- **Workflow Affinity:** Assign clients to specific workflows. Jobs are automatically routed to the correct client.
|
|
146
|
+
- **Dynamic Job Queues:** A separate job queue is created for each workflow type, preventing head-of-line blocking.
|
|
147
|
+
- **Event-Driven Architecture:** Zero polling for maximum efficiency and responsiveness.
|
|
148
|
+
- **Built-in Monitoring:** Optional real-time monitoring of client and queue states.
|
|
149
|
+
|
|
150
|
+
**Example:**
|
|
151
|
+
```ts
|
|
152
|
+
import { MultiWorkflowPool, Workflow } from "comfyui-node";
|
|
153
|
+
import SdxlWorkflow from './sdxl-workflow.json';
|
|
154
|
+
import VideoWorkflow from './video-workflow.json';
|
|
155
|
+
|
|
156
|
+
// 1. Define workflows and generate their hash for affinity mapping
|
|
157
|
+
const sdxlWF = Workflow.from(SdxlWorkflow).updateHash();
|
|
158
|
+
const videoWF = Workflow.from(VideoWorkflow).updateHash();
|
|
159
|
+
|
|
160
|
+
// 2. Create a new pool
|
|
161
|
+
const pool = new MultiWorkflowPool({
|
|
162
|
+
logLevel: "info",
|
|
163
|
+
enableMonitoring: true,
|
|
164
|
+
});
|
|
165
|
+
|
|
166
|
+
// 3. Add clients with workflow affinity
|
|
167
|
+
// This client is specialized for SDXL workflows
|
|
168
|
+
pool.addClient("http://localhost:8188", { workflowAffinity: [sdxlWF] });
|
|
169
|
+
|
|
170
|
+
// This client is specialized for Video workflows
|
|
171
|
+
pool.addClient("http://localhost:8189", { workflowAffinity: [videoWF] });
|
|
172
|
+
|
|
173
|
+
// This client is a general-purpose worker
|
|
174
|
+
pool.addClient("http://localhost:8190");
|
|
175
|
+
|
|
176
|
+
// 4. Initialize the pool (connects to all clients)
|
|
177
|
+
await pool.init();
|
|
178
|
+
|
|
179
|
+
// 5. Submit jobs
|
|
180
|
+
// The pool automatically routes them to the correct client
|
|
181
|
+
const sdxlJobId = await pool.submitJob(sdxlWF);
|
|
182
|
+
const videoJobId = await pool.submitJob(videoWF);
|
|
183
|
+
|
|
184
|
+
// 6. Wait for a job to complete
|
|
185
|
+
const results = await pool.waitForJobCompletion(sdxlJobId);
|
|
186
|
+
console.log("SDXL Job completed!", results.images);
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
## What's New in v1.6.5
|
|
190
|
+
|
|
191
|
+
- **Integration Test Infrastructure** – Comprehensive reconnection testing with real mock server processes
|
|
192
|
+
- Mock servers spawn in separate OS processes that can be killed/restarted
|
|
193
|
+
- 13 integration tests covering manual/auto-reconnection, state transitions, and multiple restart cycles
|
|
194
|
+
- Test helpers and utilities for easy test development
|
|
195
|
+
- 900+ lines of documentation with quick-start guide and examples
|
|
196
|
+
- Run with: `bun test test/integration/` or `bun run test:integration`
|
|
145
197
|
|
|
146
198
|
See [CHANGELOG.md](./CHANGELOG.md) for complete release notes.
|
|
147
199
|
|
|
@@ -200,11 +252,71 @@ job.on('failed', err => console.error(err));
|
|
|
200
252
|
|
|
201
253
|
## Testing
|
|
202
254
|
|
|
255
|
+
### Unit and Integration Tests
|
|
256
|
+
|
|
203
257
|
```bash
|
|
204
|
-
bun test
|
|
205
|
-
bun run test:
|
|
206
|
-
bun run test:
|
|
207
|
-
bun run
|
|
258
|
+
bun test # Unit + integration tests
|
|
259
|
+
bun run test:integration # Run all integration tests
|
|
260
|
+
bun run test:integration:simple # Run simple reconnection examples
|
|
261
|
+
bun run test:real # Real server tests (COMFY_REAL=1)
|
|
262
|
+
bun run test:full # Comprehensive tests (COMFY_FULL=1)
|
|
263
|
+
bun run coverage # Coverage report
|
|
264
|
+
```
|
|
265
|
+
|
|
266
|
+
### Integration Tests (v1.6.5+)
|
|
267
|
+
|
|
268
|
+
The library includes a comprehensive integration test infrastructure that spawns real mock server processes to test reconnection behavior:
|
|
269
|
+
|
|
270
|
+
```bash
|
|
271
|
+
# Run all integration tests
|
|
272
|
+
bun test test/integration/
|
|
273
|
+
|
|
274
|
+
# Run simple examples (recommended first)
|
|
275
|
+
bun run test:integration:simple
|
|
276
|
+
|
|
277
|
+
# Validate the mock server infrastructure
|
|
278
|
+
bun test/integration/validate-mock-server.ts
|
|
279
|
+
|
|
280
|
+
# Debug: Run mock server standalone
|
|
281
|
+
bun test/integration/mock-server.ts 8191
|
|
282
|
+
```
|
|
283
|
+
|
|
284
|
+
**What's Tested:**
|
|
285
|
+
- Manual and automatic reconnection after server crashes
|
|
286
|
+
- Connection state transitions (connecting → connected → disconnected → reconnecting)
|
|
287
|
+
- Event emission (`reconnected`, `reconnection_failed`)
|
|
288
|
+
- Multiple server restart cycles
|
|
289
|
+
- WebSocket message handling across reconnections
|
|
290
|
+
|
|
291
|
+
**Documentation:**
|
|
292
|
+
- `test/integration/README.md` – Comprehensive guide
|
|
293
|
+
- `test/integration/QUICKSTART.md` – Developer quick-start with patterns
|
|
294
|
+
- `test/integration/SUMMARY.md` – Architecture overview
|
|
295
|
+
|
|
296
|
+
**Example:**
|
|
297
|
+
```ts
|
|
298
|
+
// Integration test pattern
|
|
299
|
+
const manager = new ServerManager({ port: 8191 });
|
|
300
|
+
await manager.startServer(8191);
|
|
301
|
+
|
|
302
|
+
const api = new ComfyApi("http://localhost:8191");
|
|
303
|
+
await initializeClient(api);
|
|
304
|
+
|
|
305
|
+
// Kill server to simulate crash
|
|
306
|
+
await manager.killServer(8191);
|
|
307
|
+
await sleep(500);
|
|
308
|
+
|
|
309
|
+
// Restart server
|
|
310
|
+
await manager.startServer(8191);
|
|
311
|
+
|
|
312
|
+
// Verify reconnection
|
|
313
|
+
await api.reconnectWs(true);
|
|
314
|
+
await waitForConnection(api);
|
|
315
|
+
expect(api.isConnected()).toBe(true);
|
|
316
|
+
|
|
317
|
+
// Cleanup
|
|
318
|
+
api.destroy();
|
|
319
|
+
await manager.killAll();
|
|
208
320
|
```
|
|
209
321
|
|
|
210
322
|
See [Troubleshooting docs](./docs/troubleshooting.md#testing--coverage) for details.
|