Refresh item storage when a container entity reloads #1
No reviewers
Labels
No labels
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
wontfix
No milestone
No project
No assignees
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
pokebedrock/bedrock-item-database!1
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "fix/item-entity-reload"
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?
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.
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.