transitionArchetype issues 0.9.0-beta.0 (Continued)
Description
A continuation of #157 there seems to be another issue related to transitionArchetype where there are references in the archetype left behind such that references still exist to entities after they have despawned.
At Code Line: (world.allEntities[oldArchetype.entities[oldEntityIndex]] :: EntityRecord).indexInArchetype = oldEntityIndex
2025-08-14T11:11:05.756Z,4207.756348,2138,6 [FLog::Error] Error: ReplicatedStorage.Packages.Matter.World:243: attempt to index nil with 'indexInArchetype'
2025-08-14T11:11:05.757Z,4207.757324,2138,6 [FLog::Output] Info: Stack Begin
2025-08-14T11:11:05.757Z,4207.757324,2138,6 [FLog::Output] Info: Script 'ReplicatedStorage.Packages.Matter.World', Line 243 - function transitionArchetype
2025-08-14T11:11:05.757Z,4207.757324,2138,6 [FLog::Output] Info: Script 'ReplicatedStorage.Packages.Matter.World', Line 270 - function executeDespawn
2025-08-14T11:11:05.758Z,4207.758301,2138,6 [FLog::Output] Info: Script 'ReplicatedStorage.Packages.Matter.World', Line 392 - function processCommand
2025-08-14T11:11:05.758Z,4207.758301,2138,6 [FLog::Output] Info: Script 'ReplicatedStorage.Packages.Matter.World', Line 438 - function commitCommands
I tried printing all transitions during a few minutes of play and once this issue begins it seems to immediately get significantly worse. All of the following entities did a transition where the oldEntityIndex was higher than the oldNumEntities. table: 0xbe3c9aecc83826d6 is the rootArchetype, output is of the following format: print(PREPEND .. "Transitioning: ", entityId, oldArchetype, oldEntityIndex, oldNumEntities, archetype, entityIndex )
2025-08-14T11:10:30.261Z,4172.261230,3ed0,6 [FLog::Output] _Server_Transitioning: 1044 table: 0xbe3c9aecc83826d6 163 160 table: 0x29e0af6dc9294336 1
2025-08-14T11:10:30.263Z,4172.263184,3ed0,6 [FLog::Output] _Server_Transitioning: 1045 table: 0xbe3c9aecc83826d6 164 159 table: 0x6943bfc90bfb83d6 1
2025-08-14T11:10:30.265Z,4172.265625,3ed0,6 [FLog::Output] _Server_Transitioning: 1046 table: 0xbe3c9aecc83826d6 165 158 table: 0x29e0af6dc9294336 1
2025-08-14T11:10:30.266Z,4172.266602,3ed0,6 [FLog::Output] _Server_Transitioning: 1047 table: 0xbe3c9aecc83826d6 166 157 table: 0x29e0af6dc9294336 1
2025-08-14T11:10:30.268Z,4172.268555,3ed0,6 [FLog::Output] _Server_Transitioning: 1048 table: 0xbe3c9aecc83826d6 167 156 table: 0xd4ad4d448fc3a356 1
2025-08-14T11:10:30.271Z,4172.271484,3ed0,6 [FLog::Output] _Server_Transitioning: 1049 table: 0xbe3c9aecc83826d6 168 155 table: 0x29e0af6dc9294336 1
2025-08-14T11:10:30.273Z,4172.273438,3ed0,6 [FLog::Output] _Server_Transitioning: 1050 table: 0xbe3c9aecc83826d6 169 154 table: 0x29e0af6dc9294336 1
2025-08-14T11:10:30.275Z,4172.275391,3ed0,6 [FLog::Output] _Server_Transitioning: 1051 table: 0xbe3c9aecc83826d6 170 153 table: 0x29e0af6dc9294336 1
2025-08-14T11:10:30.276Z,4172.276367,3ed0,6 [FLog::Output] _Server_Transitioning: 1052 table: 0xbe3c9aecc83826d6 165 152 table: 0x6943bfc90bfb83d6 1
2025-08-14T11:10:30.278Z,4172.278320,3ed0,6 [FLog::Output] _Server_Transitioning: 1053 table: 0xbe3c9aecc83826d6 172 151 table: 0xd4ad4d448fc3a356 1
2025-08-14T11:10:30.280Z,4172.280273,3ed0,6 [FLog::Output] _Server_Transitioning: 1054 table: 0xbe3c9aecc83826d6 173 150 table: 0xd4ad4d448fc3a356 1
2025-08-14T11:10:30.282Z,4172.282227,3ed0,6 [FLog::Output] _Server_Transitioning: 1055 table: 0xbe3c9aecc83826d6 174 149 table: 0x29e0af6dc9294336 1
2025-08-14T11:10:30.284Z,4172.284180,3ed0,6 [FLog::Output] _Server_Transitioning: 1056 table: 0xbe3c9aecc83826d6 163 148 table: 0xc1d6f0407e861bb6 5
2025-08-14T11:10:30.286Z,4172.286133,3ed0,6 [FLog::Output] _Server_Transitioning: 1057 table: 0xbe3c9aecc83826d6 164 147 table: 0x29e0af6dc9294336 1
2025-08-14T11:10:30.287Z,4172.287109,3ed0,6 [FLog::Output] _Server_Transitioning: 1058 table: 0xbe3c9aecc83826d6 166 146 table: 0x29e0af6dc9294336 1
2025-08-14T11:10:30.289Z,4172.289551,3ed0,6 [FLog::Output] _Server_Transitioning: 1059 table: 0xbe3c9aecc83826d6 167 145 table: 0x29e0af6dc9294336 1
2025-08-14T11:10:30.291Z,4172.291504,3ed0,6 [FLog::Output] _Server_Transitioning: 1060 table: 0xbe3c9aecc83826d6 168 144 table: 0x29e0af6dc9294336 1
2025-08-14T11:10:30.292Z,4172.292480,3ed0,6 [FLog::Output] _Server_Transitioning: 1061 table: 0xbe3c9aecc83826d6 169 143 table: 0x29e0af6dc9294336 1
2025-08-14T11:10:30.294Z,4172.294434,3ed0,6 [FLog::Output] _Server_Transitioning: 1062 table: 0xbe3c9aecc83826d6 170 142 table: 0x118f45de1cc49df6 1
2025-08-14T11:10:30.296Z,4172.296387,3ed0,6 [FLog::Output] _Server_Transitioning: 1063 table: 0xbe3c9aecc83826d6 165 141 table: 0xd4ad4d448fc3a356 1
2025-08-14T11:10:30.298Z,4172.298340,3ed0,6 [FLog::Output] _Server_Transitioning: 1064 table: 0xbe3c9aecc83826d6 172 140 table: 0x29e0af6dc9294336 1
2025-08-14T11:10:30.299Z,4172.299316,3ed0,6 [FLog::Output] _Server_Transitioning: 1065 table: 0xbe3c9aecc83826d6 173 139 table: 0x118f45de1cc49df6 1
2025-08-14T11:10:30.300Z,4172.300293,3ed0,6 [FLog::Output] _Server_Transitioning: 1066 table: 0xbe3c9aecc83826d6 174 138 table: 0x29e0af6dc9294336 1
2025-08-14T11:10:30.302Z,4172.302246,3ed0,6 [FLog::Output] _Server_Transitioning: 1068 table: 0xbe3c9aecc83826d6 164 137 table: 0x29e0af6dc9294336 1
2025-08-14T11:10:30.305Z,4172.305176,3ed0,6 [FLog::Output] _Server_Transitioning: 1069 table: 0xbe3c9aecc83826d6 167 136 table: 0x29e0af6dc9294336 1
2025-08-14T11:10:30.307Z,4172.307129,3ed0,6 [FLog::Output] _Server_Transitioning: 1070 table: 0xbe3c9aecc83826d6 168 135 table: 0x29e0af6dc9294336 1
2025-08-14T11:10:30.309Z,4172.309082,3ed0,6 [FLog::Output] _Server_Transitioning: 1071 table: 0xbe3c9aecc83826d6 169 134 table: 0x29e0af6dc9294336 1
2025-08-14T11:10:30.311Z,4172.311035,3ed0,6 [FLog::Output] _Server_Transitioning: 1072 table: 0xbe3c9aecc83826d6 170 133 table: 0x29e0af6dc9294336 1
2025-08-14T11:10:30.313Z,4172.313477,3ed0,6 [FLog::Output] _Server_Transitioning: 1074 table: 0xbe3c9aecc83826d6 172 132 table: 0x29e0af6dc9294336 1
2025-08-14T11:10:30.315Z,4172.315430,3ed0,6 [FLog::Output] _Server_Transitioning: 1075 table: 0xbe3c9aecc83826d6 173 131 table: 0x29e0af6dc9294336 1
2025-08-14T11:10:30.316Z,4172.316406,3ed0,6 [FLog::Output] _Server_Transitioning: 1076 table: 0xbe3c9aecc83826d6 174 130 table: 0x29e0af6dc9294336 1
2025-08-14T11:10:30.318Z,4172.318359,3ed0,6 [FLog::Output] _Server_Transitioning: 1077 table: 0xbe3c9aecc83826d6 164 129 table: 0xc1d6f0407e861bb6 5
2025-08-14T11:10:30.320Z,4172.320312,3ed0,6 [FLog::Output] _Server_Transitioning: 1078 table: 0xbe3c9aecc83826d6 167 128 table: 0xc1d6f0407e861bb6 5
2025-08-14T11:10:30.320Z,4172.320312,3ed0,6 [FLog::Output] _Server_Transitioning: 1079 table: 0xbe3c9aecc83826d6 168 127 table: 0x29e0af6dc9294336 1
2025-08-14T11:10:30.323Z,4172.323242,3ed0,6 [FLog::Output] _Server_Transitioning: 1080 table: 0xbe3c9aecc83826d6 169 126 table: 0xd4ad4d448fc3a356 1
2025-08-14T11:10:30.325Z,4172.325195,3ed0,6 [FLog::Output] _Server_Transitioning: 1081 table: 0xbe3c9aecc83826d6 170 125 table: 0x29e0af6dc9294336 1
2025-08-14T11:10:30.327Z,4172.327148,3ed0,6 [FLog::Output] _Server_Transitioning: 1083 table: 0xbe3c9aecc83826d6 173 124 table: 0xd4ad4d448fc3a356 1
2025-08-14T11:10:30.330Z,4172.330078,3ed0,6 [FLog::Output] _Server_Transitioning: 1085 table: 0xbe3c9aecc83826d6 164 123 table: 0x29e0af6dc9294336 1
2025-08-14T11:10:30.331Z,4172.331055,3ed0,6 [FLog::Output] _Server_Transitioning: 1086 table: 0xbe3c9aecc83826d6 167 122 table: 0x6943bfc90bfb83d6 1
2025-08-14T11:10:30.333Z,4172.333008,3ed0,6 [FLog::Output] _Server_Transitioning: 1087 table: 0xbe3c9aecc83826d6 168 121 table: 0x6943bfc90bfb83d6 1
2025-08-14T11:10:30.333Z,4172.333984,3ed0,6 [FLog::Output] _Server_Transitioning: 1088 table: 0xbe3c9aecc83826d6 169 120 table: 0x29e0af6dc9294336 1
2025-08-14T11:10:30.336Z,4172.336426,3ed0,6 [FLog::Output] _Server_Transitioning: 1092 table: 0xbe3c9aecc83826d6 168 119 table: 0xa29b9c325ff225a6 1
2025-08-14T11:10:30.339Z,4172.339355,3ed0,6 [FLog::Output] _Server_Transitioning: 1094 table: 0xbe3c9aecc83826d6 168 118 table: 0x29e0af6dc9294336 1
2025-08-14T11:10:30.341Z,4172.341309,3ed0,6 [FLog::Output] _Server_Transitioning: 1095 table: 0xbe3c9aecc83826d6 168 117 table: 0x29e0af6dc9294336 1
2025-08-14T11:10:30.343Z,4172.343262,3ed0,6 [FLog::Output] _Server_Transitioning: 1096 table: 0xbe3c9aecc83826d6 168 116 table: 0x29e0af6dc9294336 1
2025-08-14T11:11:05.640Z,4207.640625,2138,6 [FLog::Output] _Server_Transitioning: 1016 table: 0x3eb58872e88e73c6 167 86 table: 0xbe3c9aecc83826d6 343
2025-08-14T11:11:05.712Z,4207.712402,2138,6 [FLog::Output] _Server_Transitioning: 1040 table: 0xfa2caaa670bdf956 166 17 table: 0xbe3c9aecc83826d6 330
2025-08-14T11:11:05.731Z,4207.731445,2138,6 [FLog::Output] _Server_Transitioning: 1002 table: 0xbe486e900eb25786 17 3 table: 0xbe3c9aecc83826d6 329
2025-08-14T11:11:05.752Z,4207.752441,2138,6 [FLog::Output] _Server_Transitioning: 1136 table: 0xfa2caaa670bdf956 166 9 table: 0xbe3c9aecc83826d6 329
2025-08-14T11:11:05.756Z,4207.756348,2138,6 [FLog::Output] _Server_Transitioning: 1172 table: 0xfa2caaa670bdf956 166 8 table: 0xbe3c9aecc83826d6 329
Steps to reproduce
Still working on a minimal reproduction, but I'm struggling to see what's causing this to happen.
As a side note, once this happens, it forever breaks commitCommands and everything else because commitCommands doesn't table.clear until after all commands have been processed. Might be good to provide some sort of failover in general.