Skip to content

Commit eb84b56

Browse files
authored
fix(macos): fail promptly after terminal gateway startup errors (#126697)
1 parent 649202a commit eb84b56

2 files changed

Lines changed: 11 additions & 1 deletion

File tree

‎apps/macos/Sources/OpenClaw/GatewayProcessManager.swift‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1010,6 +1010,15 @@ extension GatewayProcessManager {
10101010
let startGeneration = self.gatewayStartGeneration
10111011
if await self.observeCurrentGatewayStart(generation: startGeneration) == true { return true }
10121012
guard !Task.isCancelled, self.isCurrentGatewayStart(startGeneration) else { return false }
1013+
// Only a real launch candidate/install can recover after its owner reports failure.
1014+
if case .failed = self.status,
1015+
!launchAgentInstalled,
1016+
self.launchAgentReadinessCandidate == nil,
1017+
self.launchAgentReadinessFailure == nil,
1018+
self.launchAgentInstallGeneration != startGeneration
1019+
{
1020+
return false
1021+
}
10131022
let readinessPort = self.launchAgentReadinessCandidate?.failure.port
10141023
?? GatewayEnvironment.gatewayPort()
10151024
let context = self.gatewayReadinessContext(

‎apps/macos/Tests/OpenClawIPCTests/GatewayProcessManagerTests.swift‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1560,7 +1560,7 @@ struct GatewayProcessManagerTests {
15601560

15611561
@Test func `readiness timeout preserves a concrete launch failure`() async throws {
15621562
let url = try #require(URL(string: "ws://example.invalid"))
1563-
let (_, connection, manager) = self.makeGatewayReadinessFixture(url: url) {
1563+
let (session, connection, manager) = self.makeGatewayReadinessFixture(url: url) {
15641564
GatewayTestWebSocketTask(
15651565
receiveHook: { _, receiveIndex in
15661566
if receiveIndex == 0 {
@@ -1581,6 +1581,7 @@ struct GatewayProcessManagerTests {
15811581
}
15821582

15831583
#expect(await manager.waitForGatewayReady(timeout: 0.1) == false)
1584+
#expect(session.snapshotMakeCount() == 0)
15841585
#expect(manager.status == .failed("launchd install denied"))
15851586
#expect(manager.lastFailureReason == "launchd install denied")
15861587
await connection.shutdown()

0 commit comments

Comments
 (0)