@mindexec/cli 0.2.140 → 0.2.141
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/package.json +1 -1
- package/scripts/remote-agent-managed-smoke.mjs +34 -0
- package/server.js +1 -1
package/package.json
CHANGED
|
@@ -124,6 +124,30 @@ function spawnBridge({ bridgePort, remoteHubPort, workspacePath, label }) {
|
|
|
124
124
|
};
|
|
125
125
|
}
|
|
126
126
|
|
|
127
|
+
async function startHangingRemoteManager(port) {
|
|
128
|
+
const sockets = new Set();
|
|
129
|
+
const server = net.createServer(socket => {
|
|
130
|
+
sockets.add(socket);
|
|
131
|
+
socket.on('close', () => sockets.delete(socket));
|
|
132
|
+
socket.on('error', () => sockets.delete(socket));
|
|
133
|
+
});
|
|
134
|
+
server.unref();
|
|
135
|
+
await new Promise((resolve, reject) => {
|
|
136
|
+
server.once('error', reject);
|
|
137
|
+
server.listen(port, '127.0.0.1', resolve);
|
|
138
|
+
});
|
|
139
|
+
|
|
140
|
+
return {
|
|
141
|
+
endpoint: `127.0.0.1:${port}`,
|
|
142
|
+
async stop() {
|
|
143
|
+
for (const socket of sockets) {
|
|
144
|
+
socket.destroy();
|
|
145
|
+
}
|
|
146
|
+
await new Promise(resolve => server.close(resolve));
|
|
147
|
+
}
|
|
148
|
+
};
|
|
149
|
+
}
|
|
150
|
+
|
|
127
151
|
async function waitForBridge(bridge) {
|
|
128
152
|
return await waitFor(async () => {
|
|
129
153
|
const result = await fetchJson(`${bridge.baseUrl}/api/status`);
|
|
@@ -159,11 +183,13 @@ async function main() {
|
|
|
159
183
|
const clientRemotePort = await findFreePort();
|
|
160
184
|
const stalePort = await findFreePort();
|
|
161
185
|
const managerEndpoint = `127.0.0.1:${hostRemotePort}`;
|
|
186
|
+
let hangingManager = null;
|
|
162
187
|
const staleEndpoint = `127.0.0.1:${stalePort}`;
|
|
163
188
|
|
|
164
189
|
let hostBridge = null;
|
|
165
190
|
let clientBridge = null;
|
|
166
191
|
try {
|
|
192
|
+
hangingManager = await startHangingRemoteManager(stalePort);
|
|
167
193
|
hostBridge = spawnBridge({
|
|
168
194
|
bridgePort: hostBridgePort,
|
|
169
195
|
remoteHubPort: hostRemotePort,
|
|
@@ -180,11 +206,16 @@ async function main() {
|
|
|
180
206
|
});
|
|
181
207
|
await waitForBridge(clientBridge);
|
|
182
208
|
|
|
209
|
+
const firstConnectStartedAt = Date.now();
|
|
183
210
|
const firstAgent = await connectManagedAgent(clientBridge, managerEndpoint, staleEndpoint);
|
|
211
|
+
const firstConnectMs = Date.now() - firstConnectStartedAt;
|
|
184
212
|
assert.equal(firstAgent.running, true, JSON.stringify(firstAgent));
|
|
185
213
|
assert.equal(firstAgent.ready, true, JSON.stringify(firstAgent));
|
|
186
214
|
assert.equal(firstAgent.usingNpx, false, JSON.stringify(firstAgent));
|
|
187
215
|
assert.match(String(firstAgent.launcher || ''), /mindexec-remote-fast/i);
|
|
216
|
+
assert.ok(
|
|
217
|
+
firstConnectMs < 4500,
|
|
218
|
+
`managed RemoteAgent must race slow endpoint candidates instead of waiting sequentially, got ${firstConnectMs}ms`);
|
|
188
219
|
|
|
189
220
|
const connectedDevice = await waitFor(async () => {
|
|
190
221
|
const result = await fetchJson(`${hostBridge.baseUrl}/api/remote/devices`);
|
|
@@ -218,6 +249,9 @@ async function main() {
|
|
|
218
249
|
|
|
219
250
|
console.log('RemoteAgent managed supervisor smoke OK');
|
|
220
251
|
} finally {
|
|
252
|
+
if (hangingManager) {
|
|
253
|
+
await hangingManager.stop();
|
|
254
|
+
}
|
|
221
255
|
if (clientBridge) {
|
|
222
256
|
await clientBridge.stop();
|
|
223
257
|
}
|
package/server.js
CHANGED
|
@@ -3132,7 +3132,7 @@ const REMOTE_AGENT_EARLY_EXIT_MS = 1200;
|
|
|
3132
3132
|
const REMOTE_AGENT_READY_TIMEOUT_MS = 5000;
|
|
3133
3133
|
const REMOTE_AGENT_DEFAULT_ENGINE = 'auto';
|
|
3134
3134
|
const REMOTE_AGENT_SYNC_REPORT_LOG_REPEAT_MS = 30000;
|
|
3135
|
-
const REMOTE_AGENT_RACE_START_STAGGER_MS =
|
|
3135
|
+
const REMOTE_AGENT_RACE_START_STAGGER_MS = Math.max(0, Number(process.env.MINDEXEC_REMOTE_AGENT_RACE_STAGGER_MS ?? 0) || 0);
|
|
3136
3136
|
const REMOTE_AGENT_MAX_PARALLEL_CANDIDATES = 6;
|
|
3137
3137
|
const REMOTE_AGENT_RECENT_MANAGER_CACHE_TTL_MS = 30 * 24 * 60 * 60 * 1000;
|
|
3138
3138
|
const REMOTE_AGENT_RECENT_MANAGER_CACHE_LIMIT = 64;
|