FOCAS/AbLegacy InitializeAsync orphans previous DeviceState loops when called without teardown #630
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Found by review R5 (#602).
FocasDriver.InitializeAsync(:207) and:180) overwriteAbLegacyDriver.InitializeAsync(_devices[host] = new DeviceState(...)without cancelling, joining or disposing the old state's probe, recycle and fixed-tree loops (each holding a client).DriverInstanceActor.AdoptConfigDuringInit(~:831) callsInitializeAsyncwithoutteardownFirst, so an ApplyDelta that arrives mid-init orphans a full loop set that neitherShutdownAsyncnor the new shutdown join (#602 STAB-23/6) can reach.This is the dispose-before-overwrite rule from the comms-loss section of CLAUDE.md, which Modbus and MQTT already follow.
InitializeAsyncin both drivers, cancel, bounded-join and dispose any existing_devicesentriesFiled 2026-10-08 by the hardware-available issue sweep.
Fixed in
2377da3c(Merge b626-630): FOCAS, AbLegacy, AbCip, TwinCAT, S7 and OpcUaClient InitializeAsync now release prior device/session state (cancel, bounded join, dispose) before re-initialising.