channel-worker 2.1.5 → 2.1.7
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/lib/command-poller.js +4 -5
- package/lib/nst-manager.js +12 -2
- package/package.json +1 -1
package/lib/command-poller.js
CHANGED
|
@@ -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 =
|
|
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 {
|
|
@@ -1190,9 +1190,8 @@ class CommandPoller {
|
|
|
1190
1190
|
if (hb && (now - hb) < HEARTBEAT_STALE) continue;
|
|
1191
1191
|
console.log(`[scene-dispatch] Stuck: ${r.name} running but heartbeat stale (${hb ? Math.round((now - hb) / 1000) + 's' : 'never'}) — restarting`);
|
|
1192
1192
|
try {
|
|
1193
|
-
await this.nst.stopProfile(r.nst_profile_id).catch(() => {});
|
|
1194
1193
|
await this.api.resetRendererCommands(r.nst_profile_id);
|
|
1195
|
-
await this._launchRendererProfile(r);
|
|
1194
|
+
await this._launchRendererProfile(r, { forceRelaunch: true });
|
|
1196
1195
|
console.log(`[scene-dispatch] ${r.name} restarted`);
|
|
1197
1196
|
} catch (err) {
|
|
1198
1197
|
console.error(`[scene-dispatch] Failed to restart ${r.name}: ${err.message}`);
|
|
@@ -1245,7 +1244,7 @@ class CommandPoller {
|
|
|
1245
1244
|
this._dispatching = false;
|
|
1246
1245
|
}
|
|
1247
1246
|
|
|
1248
|
-
async _launchRendererProfile(renderer) {
|
|
1247
|
+
async _launchRendererProfile(renderer, options = {}) {
|
|
1249
1248
|
await this.nst.ensureProfile(renderer.nst_profile_id, { os: renderer.os || 'windows', proxy: renderer.proxy || null });
|
|
1250
1249
|
|
|
1251
1250
|
const path = require('path');
|
|
@@ -1280,7 +1279,7 @@ class CommandPoller {
|
|
|
1280
1279
|
console.warn(`[scene-dispatch] Ext dir failed: ${e.message}, using base`);
|
|
1281
1280
|
}
|
|
1282
1281
|
|
|
1283
|
-
await this.nst.launchProfile(renderer.nst_profile_id, { proxy: renderer.proxy || null, extensionPath });
|
|
1282
|
+
await this.nst.launchProfile(renderer.nst_profile_id, { proxy: renderer.proxy || null, extensionPath, forceRelaunch: options.forceRelaunch });
|
|
1284
1283
|
}
|
|
1285
1284
|
|
|
1286
1285
|
// ─── Profile Timeout ───────────────────────────────────────────────────────
|
package/lib/nst-manager.js
CHANGED
|
@@ -153,8 +153,18 @@ class NstManager {
|
|
|
153
153
|
console.log(`[nst] Running browsers: ${running.map(b => b.name || b.profileId).join(', ') || 'none'}`);
|
|
154
154
|
const isRunning = running.some(b => b.profileId === profileId);
|
|
155
155
|
if (isRunning) {
|
|
156
|
-
|
|
157
|
-
|
|
156
|
+
if (options.forceRelaunch) {
|
|
157
|
+
console.log(`[nst] Profile ${profileId} already running — force stopping for relaunch`);
|
|
158
|
+
try {
|
|
159
|
+
await this.stopProfile(profileId);
|
|
160
|
+
await new Promise(r => setTimeout(r, 3000));
|
|
161
|
+
} catch (e) {
|
|
162
|
+
console.warn(`[nst] Stop failed: ${e.message}`);
|
|
163
|
+
}
|
|
164
|
+
} else {
|
|
165
|
+
console.log(`[nst] Profile ${profileId} already running — skipping launch`);
|
|
166
|
+
return { profileId, alreadyRunning: true };
|
|
167
|
+
}
|
|
158
168
|
}
|
|
159
169
|
|
|
160
170
|
// Update profile language to en-US (Custom) before launch
|