channel-worker 2.2.1 → 2.2.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.
@@ -1214,7 +1214,9 @@ class CommandPoller {
1214
1214
  const stillOffline = renderers.filter(r => !runningRenderers.includes(r));
1215
1215
  console.log(`[scene-dispatch] running=${runningRenderers.length}/${parallelLimit} offline=${stillOffline.length} queue=${queueCount} names=[${runningRenderers.map(r=>r.name)}]`);
1216
1216
 
1217
- const neededLaunches = Math.min(parallelLimit - runningRenderers.length, stillOffline.length, queueCount);
1217
+ // Only launch if queue has more work than running profiles can handle
1218
+ const freeSlots = Math.max(0, queueCount - runningRenderers.length);
1219
+ const neededLaunches = Math.min(parallelLimit - runningRenderers.length, stillOffline.length, freeSlots);
1218
1220
  for (let li = 0; li < neededLaunches; li++) {
1219
1221
  const toLaunch = stillOffline[li];
1220
1222
  console.log(`[scene-dispatch] Launching ${toLaunch.name} (running: ${runningRenderers.length + li}/${parallelLimit})`);
@@ -1308,12 +1310,18 @@ class CommandPoller {
1308
1310
 
1309
1311
  for (const browser of running) {
1310
1312
  const profileId = browser.profileId;
1311
- const lastActivity = this._profileLastActivity[profileId] || 0;
1312
- if (lastActivity && (now - lastActivity) > IDLE_TIMEOUT) {
1313
+ const name = browser.name?.toLowerCase();
1314
+ // Match by UUID or name (renderers use name as nst_profile_id)
1315
+ const lastActivity = this._profileLastActivity[profileId]
1316
+ || (name && this._profileLastActivity[name])
1317
+ || 0;
1318
+ if (!lastActivity) continue; // never tracked — skip (just launched by another process)
1319
+ if ((now - lastActivity) > IDLE_TIMEOUT) {
1313
1320
  console.log(`[profile-timeout] Closing idle profile ${browser.name || profileId} (idle ${Math.round((now - lastActivity) / 1000)}s)`);
1314
1321
  try {
1315
1322
  await this.nst.stopProfile(profileId);
1316
1323
  delete this._profileLastActivity[profileId];
1324
+ if (name) delete this._profileLastActivity[name];
1317
1325
  } catch (e) {
1318
1326
  console.warn(`[profile-timeout] Failed to close ${profileId}: ${e.message}`);
1319
1327
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "channel-worker",
3
- "version": "2.2.1",
3
+ "version": "2.2.3",
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": {