Refresh item storage when a container entity reloads #1

Merged
smell-of-curry merged 1 commit from fix/item-entity-reload into main 2026-11-09 23:12:11 +00:00

An entity unload removes its handle but retains its item map. Reloading that same entity then asserts that the retained map is empty and aborts registration. Read the complete inventory before atomically replacing its cache and handle, remove stale entries, and allow retry after an interrupted inventory read.

Validation: three Node regression tests fail against the original implementation and pass with this change. TypeScript passes with --ignoreDeprecations 6.0 (the existing node10 module-resolution setting is deprecated by the installed compiler). No production data migration.

An entity unload removes its handle but retains its item map. Reloading that same entity then asserts that the retained map is empty and aborts registration. Read the complete inventory before atomically replacing its cache and handle, remove stale entries, and allow retry after an interrupted inventory read. Validation: three Node regression tests fail against the original implementation and pass with this change. TypeScript passes with --ignoreDeprecations 6.0 (the existing node10 module-resolution setting is deprecated by the installed compiler). No production data migration.
bot left a comment

Desk review @5b1ee3d7: no blockers. Moving databaseEntities.set into registerEntityItems after the full read is a clean fix, and the tests cover reload, stale entries, and retry.

Nits: (1) cachedItems.delete(oldId) on reload would also drop an id that another entity still holds if ids ever collide across entities; fine if ids are unique, worth a comment. (2) The tests bundle with esbuild (already a devDependency), so no new deps. (3) Callers of registerEntityItems that previously relied on databaseEntities being set before the call (none seen in the diff) should be double-checked. Merge is Curry's.

Desk review @5b1ee3d7: no blockers. Moving databaseEntities.set into registerEntityItems after the full read is a clean fix, and the tests cover reload, stale entries, and retry. Nits: (1) cachedItems.delete(oldId) on reload would also drop an id that another entity still holds if ids ever collide across entities; fine if ids are unique, worth a comment. (2) The tests bundle with esbuild (already a devDependency), so no new deps. (3) Callers of registerEntityItems that previously relied on databaseEntities being set before the call (none seen in the diff) should be double-checked. Merge is Curry's.
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
pokebedrock/bedrock-item-database!1
No description provided.