channel-worker 2.1.6 → 2.2.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.
@@ -1179,7 +1179,7 @@ class CommandPoller {
1179
1179
 
1180
1180
  // 3b. Running profiles with stale heartbeat + PENDING commands → extension never started
1181
1181
  // Only restart if commands are still "pending" (not "running" = extension picked up but busy)
1182
- const HEARTBEAT_STALE = 3 * 60 * 1000; // 3 minutes (extension can be busy rendering for 5+ min)
1182
+ const HEARTBEAT_STALE = 30 * 1000; // 30s extension heartbeats every 15s even when busy
1183
1183
  const now = Date.now();
1184
1184
  for (const r of [...runningRenderers]) {
1185
1185
  try {
@@ -1226,17 +1226,18 @@ class CommandPoller {
1226
1226
  return;
1227
1227
  }
1228
1228
 
1229
- // 7. Assign queued commands round-robin across running renderers
1229
+ // 7. Assign 1 command per free profile (no pending/running commands)
1230
1230
  let assigned = 0;
1231
- for (let qi = 0; qi < queueCount; qi++) {
1232
- const target = runningRenderers[qi % runningRenderers.length];
1233
- const cmd = await this.api.sceneDispatch(target.nst_profile_id);
1234
- if (!cmd) break; // queue empty
1235
- this._profileLastActivity[target.nst_profile_id] = Date.now();
1236
- assigned++;
1237
- }
1238
- if (assigned > 0) {
1239
- console.log(`[scene-dispatch] Assigned ${assigned} commands across ${runningRenderers.length} renderers`);
1231
+ for (const r of runningRenderers) {
1232
+ try {
1233
+ const cmdCount = await this.api.rendererHasCommands(r.nst_profile_id);
1234
+ if (cmdCount > 0) continue; // already has work
1235
+ const cmd = await this.api.sceneDispatch(r.nst_profile_id);
1236
+ if (!cmd) break; // queue empty
1237
+ this._profileLastActivity[r.nst_profile_id] = Date.now();
1238
+ assigned++;
1239
+ console.log(`[scene-dispatch] Assigned ${cmd.type} ${r.name}`);
1240
+ } catch {}
1240
1241
  }
1241
1242
  } catch (err) {
1242
1243
  console.error(`[scene-dispatch] Error: ${err.message}`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "channel-worker",
3
- "version": "2.1.6",
3
+ "version": "2.2.0",
4
4
  "description": "Channel Manager worker daemon — runs on remote machines to execute video pipeline jobs",
5
5
  "main": "lib/daemon.js",
6
6
  "bin": {