"Error while running event smart-enemy-ai::on_load() Detected modifications to the 'storage' table: CRC before: 2377011795 CRC after: 3206629390. This indicates the mod is not save/load stable and not multiplayer safe. on_load() should never change the storage table."
Bug report: Smart Enemies 6.2.1 breaks save/load stability
Factorio version: (fill in your version)
Mod version: Smart Enemies 6.2.1
Issue:
The mod causes a deterministic crash when loading a save with the following error:
Error while running event smart-enemy-ai::on_load()
Detected modifications to the 'storage' table:
CRC before: 2377011795
CRC after: 3206629390.
This indicates the mod is not save/load stable and not multiplayer safe.
on_load() should never change the storage table.
Cause (code-level):
The mod modifies storage inside on_load(), which is explicitly forbidden in Factorio.
Relevant code:
control.lua
script.on_load(function()
state.on_load()
end)
lib/state.lua
function M.on_load()
if storage and storage.path_q then
storage.path_q.pending = {}
end
end
This line:
storage.path_q.pending = {}
mutates persistent state during on_load, causing the CRC mismatch.
Why this is wrong:
Factorio requires on_load() to be strictly read-only. Any modification to storage will break determinism and trigger this exact error.
Suggested fix:
Do not modify storage in on_load().
Minimal fix:
function M.on_load()
-- no-op
end
Alternative (if cleanup is required):
Defer the mutation to the first tick after load:
script.on_load(function()
script.on_nth_tick(1, function()
if storage and storage.path_q then
storage.path_q.pending = {}
end
script.on_nth_tick(1, nil)
end)
end)
Conclusion:
The mod is currently not save/load safe and not multiplayer safe due to illegal state mutation in on_load().