fix(parallels): pace background launch probes · openclaw/openclaw@ecac665
vincentkoc
·
2026-06-21
·
via Recent Commits to openclaw:main
| Original file line number | Diff line number | Diff line change |
|---|
@@ -191,10 +191,11 @@ Write-OpenClawUtf8File $pidPath ([string]$process.Id)
|
191 | 191 | } |
192 | 192 | lastLaunchStatus = launch.status; |
193 | 193 | if (launch.status === 0 || launch.status === 124) { |
194 | | -const materialized = waitForWindowsBackgroundMaterialized({ |
| 194 | +const materialized = await waitForWindowsBackgroundMaterialized({ |
195 | 195 | append, |
196 | 196 | deadline, |
197 | 197 | pathsScript, |
| 198 | + pollIntervalMs, |
198 | 199 | runCommand, |
199 | 200 | vmName: options.vmName, |
200 | 201 | }); |
@@ -309,13 +310,14 @@ function hasControlLine(output: string, marker: string): boolean {
|
309 | 310 | return output.split(/\r?\n/u).some((entry) => entry.trimEnd() === marker); |
310 | 311 | } |
311 | 312 | |
312 | | -function waitForWindowsBackgroundMaterialized(params: { |
| 313 | +async function waitForWindowsBackgroundMaterialized(params: { |
313 | 314 | append?: (chunk: string | Uint8Array) => void; |
314 | 315 | deadline: number; |
315 | 316 | pathsScript: string; |
| 317 | +pollIntervalMs: number; |
316 | 318 | runCommand: typeof run; |
317 | 319 | vmName: string; |
318 | | -}): boolean { |
| 320 | +}): Promise<boolean> { |
319 | 321 | const materializeDeadline = Math.min(Date.now() + 45_000, params.deadline); |
320 | 322 | while (Date.now() < materializeDeadline) { |
321 | 323 | const result = params.runCommand( |
@@ -340,6 +342,7 @@ if ((Test-Path $logPath) -or (Test-Path $donePath)) {
|
340 | 342 | if (result.stdout.includes("materialized")) { |
341 | 343 | return true; |
342 | 344 | } |
| 345 | +await sleep(Math.min(params.pollIntervalMs, Math.max(1, materializeDeadline - Date.now()))); |
343 | 346 | } |
344 | 347 | return false; |
345 | 348 | } |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -40,7 +40,11 @@ import {
|
40 | 40 | validateSnapshotRestoreMode, |
41 | 41 | withProgressOnStderr, |
42 | 42 | } from "../../scripts/e2e/parallels/common.ts"; |
43 | | -import { LinuxGuest, MacosGuest } from "../../scripts/e2e/parallels/guest-transports.ts"; |
| 43 | +import { |
| 44 | +LinuxGuest, |
| 45 | +MacosGuest, |
| 46 | +runWindowsBackgroundPowerShell, |
| 47 | +} from "../../scripts/e2e/parallels/guest-transports.ts"; |
44 | 48 | import { resolveHostCommandInvocation } from "../../scripts/e2e/parallels/host-command.ts"; |
45 | 49 | import { testing as hostServerTesting } from "../../scripts/e2e/parallels/host-server.ts"; |
46 | 50 | import { parseArgs as parseLinuxSmokeArgs } from "../../scripts/e2e/parallels/linux-smoke.ts"; |
@@ -1381,6 +1385,27 @@ if (isPrlctl) {
|
1381 | 1385 | expect(transports).toContain("waitForWindowsBackgroundMaterialized"); |
1382 | 1386 | }); |
1383 | 1387 | |
| 1388 | +it("paces ambiguous Windows background launch materialization probes", async () => { |
| 1389 | +let calls = 0; |
| 1390 | +const runCommand = vi.fn(() => { |
| 1391 | +calls++; |
| 1392 | +return { status: 0, stderr: "", stdout: "" }; |
| 1393 | +}); |
| 1394 | + |
| 1395 | +await expect( |
| 1396 | +runWindowsBackgroundPowerShell({ |
| 1397 | +label: "ambiguous launch", |
| 1398 | +pollIntervalMs: 20, |
| 1399 | + runCommand, |
| 1400 | +script: "Write-Output ok", |
| 1401 | +timeoutMs: 90, |
| 1402 | +vmName: "Windows 11", |
| 1403 | +}), |
| 1404 | +).rejects.toThrow("ambiguous launch background launch failed"); |
| 1405 | + |
| 1406 | +expect(calls).toBeLessThan(20); |
| 1407 | +}); |
| 1408 | + |
1384 | 1409 | it("returns timed-out host command status when check is disabled", () => { |
1385 | 1410 | const result = run( |
1386 | 1411 | process.execPath, |
|
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。