Skip to content

Commit eb4add3

Browse files
committed
fix(connection): preserve parent recovery and fencing semantics
Co-authored-by: Copilot App <[email protected]> Copilot-Session: 59c9cc10-f388-47ba-a6a0-2afd21dff031
1 parent 54da567 commit eb4add3

3 files changed

Lines changed: 10 additions & 5 deletions

File tree

‎src/OpenClaw.Connection/BootstrapTokenLifecycle.cs‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -472,6 +472,7 @@ private bool TryClearBootstrapTokenUnderLease(
472472
"credential",
473473
"Failed to persist cleared bootstrap token",
474474
ex.Message);
475+
return false;
475476
}
476477

477478
return true;

‎src/OpenClaw.Connection/NodeConnectionCoordinator.cs‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -640,7 +640,8 @@ await _nodeConnector.ConnectAsync(
640640
}
641641
catch (DeviceIdentityLoadException ex)
642642
{
643-
if (!IsCurrentNodeAttempt(attempt))
643+
if (cancellationToken.IsCancellationRequested ||
644+
!IsCurrentNodeAttempt(attempt))
644645
return new(NodeStartOutcome.Superseded);
645646

646647
var detail = BuildIdentityFailureDetail(ex);
@@ -663,7 +664,8 @@ await _stateSink.PublishNodeBlockedAsync(
663664
}
664665
catch (Exception ex)
665666
{
666-
if (!IsCurrentNodeAttempt(attempt))
667+
if (cancellationToken.IsCancellationRequested ||
668+
!IsCurrentNodeAttempt(attempt))
667669
return new(NodeStartOutcome.Superseded);
668670

669671
_logger.Error($"[ConnMgr] Node connect failed: {ex.Message}");

‎tests/OpenClaw.Connection.Tests/BootstrapTokenLifecycleTests.cs‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ public async Task StaleAttempt_DoesNotClearNewerRecord()
8181
}
8282

8383
[Fact]
84-
public async Task SaveFailure_PreservesExistingInMemoryClearBehavior()
84+
public async Task SaveFailure_RestoresBootstrapForRetry()
8585
{
8686
using var temp = new TempDirectory("openclaw-bootstrap-save-");
8787
var registry = CreateDurablyPairedRegistry(
@@ -95,8 +95,10 @@ public async Task SaveFailure_PreservesExistingInMemoryClearBehavior()
9595
new GatewayAttemptStamp(1, "gw-1"),
9696
CancellationToken.None);
9797

98-
Assert.True(cleared);
99-
Assert.Null(registry.GetById("gw-1")?.BootstrapToken);
98+
Assert.False(cleared);
99+
Assert.Equal(
100+
"bootstrap-secret",
101+
registry.GetById("gw-1")?.BootstrapToken);
100102
}
101103

102104
[Fact]

0 commit comments

Comments
 (0)