mirror of
https://github.com/ElectronNET/Electron.NET.git
synced 2026-11-16 09:21:01 +00:00
fix(runtime): stop the socket bridge when it never connected
When Electron exits before the socket bridge connects (for example because another instance holds the single-instance lock), RuntimeControllerDotNetFirst stops the bridge, but SocketBridgeService only reaches Stopped through BridgeDisconnected, which a never-connected socket does not raise. The controller then never reaches Stopped and the .NET host hangs forever. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -51,6 +51,19 @@
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
public override async Task Stop()
|
||||
{
|
||||
await base.Stop().ConfigureAwait(false);
|
||||
|
||||
// A socket that never connected never raises BridgeDisconnected, so without this the bridge stays in
|
||||
// Stopping forever. That happens when Electron exits before the bridge connects (e.g. it lost the
|
||||
// single-instance lock), and the runtime controller then never reaches Stopped, hanging the .NET host.
|
||||
if (this.State < LifetimeState.Stopped)
|
||||
{
|
||||
this.TransitionState(LifetimeState.Stopped);
|
||||
}
|
||||
}
|
||||
|
||||
private void Connect()
|
||||
{
|
||||
this.socket.Connect();
|
||||
|
||||
Reference in New Issue
Block a user