[BUG]: ReferenceHub::connectionToClient.address getter throws error when client is disconnected
Before You Report
- [x] I have searched for existing reports of this bug, and this bug report is unique.
Version
1.1.6, this is specifically a base game bug for the 14.2.6 beta
Description
When you use an event like PlayerLeft and then construct a footprint from that event, your code will now throw an error despite it still working last update. This happens due to (see title)
To Reproduce
subscribe to PlayerLeft event and then call the ReferenceHub::connectionToClient.address getter in 14.2.6
Expected Behavior
No error should happen
Additional Information
From what I can see in the base game code from previous SL versions, SL never actually cleared out the Peers array (now dictionary) in the custom mirror server implementation, I think this meant that peers actually stayed cached even after one disconnected or something? I dont fully know to be honest, you'd have to ask somebody who worked on the new custom mirror stuff tbh. Anyways, the new implementation actively removes peers from the dictionary so if I was correct, then really you could fix this by just not trying to remove peers from the dictionary when they disconnect, or you could just add a check to the footprint constructor to fix my use case specifically
Can you provide the error at all so we get a better understanding of the issue?
I know this isnt ideal, but I had to look through my LA logs for this. What happened is I disconnected, then my role got set to spectator and the spawn reason was not destroyed somehow, then because of an Exiled config where you're supposed to drop all your items, ServerDropEverything was called which then needed to make footprints for the previous owner of the items. Do keep in mind that in this case specifically ServerDropAmmo caused the error, due to Exiled patching in setting PreviousOwner for that, but the same error would have occurred on ServerDropItem instead. Furthermore the same method would have been called by the base game (if you have the disconnect drop config on). Also I think because the new mirror stuff uses concurrent dictionaries, I'm struggling to recreate this.
[2026-03-24 22:52:42.738 -04:00] Player Someone disconnected
[2026-03-24 22:52:42.772 -04:00] [STDOUT] Cannot set the parent of the GameObject 'SpectatorRole(Clone)' while its new parent 'Player [connId=1]' is being destroyed
[2026-03-24 22:52:42.801 -04:00] [ERROR] [Exiled.Events] Method "OnChangingRole" of the class "Exiled.Events.Handlers.Internal.Round" caused an exception when handling the event "Exiled.Events.Features.Event`1[[Exiled.Events.EventArgs.Player.ChangingRoleEventArgs, Exiled.Events, Version=9.13.1.0, Culture=neutral, PublicKeyToken=null]]"
System.Collections.Generic.KeyNotFoundException: The given key '1' was not present in the dictionary.
at System.Collections.Concurrent.ConcurrentDictionary`2[TKey,TValue].ThrowKeyNotFoundException (System.Object key) [0x00010] in <13c0c460649d4ce49f991e2c222fa635>:0
at System.Collections.Concurrent.ConcurrentDictionary`2[TKey,TValue].get_Item (TKey key) [0x0000b] in <13c0c460649d4ce49f991e2c222fa635>:0
at Mirror.LiteNetLib4Mirror.LiteNetLib4MirrorServer.GetClientAddress (System.Int32 connectionId) [0x00000] in <72fad981453040f3bc624246ce4a913a>:0
at Mirror.LiteNetLib4Mirror.LiteNetLib4MirrorTransport.ServerGetClientAddress (System.Int32 connectionId) [0x00000] in <72fad981453040f3bc624246ce4a913a>:0
at Mirror.NetworkConnectionToClient.get_OriginalIpAddress () [0x00000] in <1bebde0895f14b11be97fb0c4e2cabe4>:0
at Mirror.NetworkConnectionToClient.get_address () [0x0000a] in <1bebde0895f14b11be97fb0c4e2cabe4>:0
at Footprinting.Footprint..ctor (ReferenceHub hub) [0x000ee] in <72fad981453040f3bc624246ce4a913a>:0
at (wrapper dynamic-method) InventorySystem.InventoryExtensions.InventorySystem.InventoryExtensions.ServerDropAmmo_Patch0(InventorySystem.Inventory,ItemType,uint16,bool)
at InventorySystem.InventoryExtensions.ServerDropEverything (InventorySystem.Inventory inv) [0x00092] in <72fad981453040f3bc624246ce4a913a>:0
at Exiled.Events.Handlers.Internal.Round.OnChangingRole (Exiled.Events.EventArgs.Player.ChangingRoleEventArgs ev) [0x0003b] in <6d81dc63d0db469d8ea7e26e0e5f2404>:0
at Exiled.Events.Features.Event`1[T].BlendedInvoke (T arg) [0x00088] in <6d81dc63d0db469d8ea7e26e0e5f2404>:0
When the OnChaningRole run (I assume) is run after the client peer is removed. I recommend implement a Prefix patch in LiteNetLib4MirrorServer.OnPeerDisconnected so you still have the Peer & can get the connection / player before it actually gets destroyed. (so the disconnect on drop run before the role actually changes & you can still create a footprint)
We will add Leaving event to overcome this + other issues