channel-worker 1.6.11 → 1.6.13
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/nst-manager.js +12 -4
- package/package.json +1 -1
package/lib/nst-manager.js
CHANGED
|
@@ -20,7 +20,7 @@ class NstManager {
|
|
|
20
20
|
// Get all running browsers
|
|
21
21
|
async getRunningBrowsers() {
|
|
22
22
|
try {
|
|
23
|
-
const rawRes = await fetch(`${this.baseUrl}/browsers
|
|
23
|
+
const rawRes = await fetch(`${this.baseUrl}/browsers`, {
|
|
24
24
|
headers: { 'x-api-key': this.apiKey },
|
|
25
25
|
});
|
|
26
26
|
const text = await rawRes.text();
|
|
@@ -127,10 +127,18 @@ class NstManager {
|
|
|
127
127
|
}
|
|
128
128
|
|
|
129
129
|
// If already running, stop first then relaunch
|
|
130
|
-
|
|
130
|
+
const running = await this.getRunningBrowsers();
|
|
131
|
+
console.log(`[nst] Running browsers: ${running.map(b => b.name || b.profileId).join(', ') || 'none'}`);
|
|
132
|
+
const isRunning = running.some(b => b.profileId === profileId);
|
|
133
|
+
if (isRunning) {
|
|
131
134
|
console.log(`[nst] Profile ${profileId} already running — stopping first`);
|
|
132
|
-
|
|
133
|
-
|
|
135
|
+
try {
|
|
136
|
+
await this.stopProfile(profileId);
|
|
137
|
+
console.log(`[nst] Stop command sent, waiting 3s...`);
|
|
138
|
+
await new Promise(r => setTimeout(r, 3000));
|
|
139
|
+
} catch (e) {
|
|
140
|
+
console.warn(`[nst] Stop failed: ${e.message} — continuing anyway`);
|
|
141
|
+
}
|
|
134
142
|
}
|
|
135
143
|
|
|
136
144
|
// Update profile language to en-US (Custom) before launch
|