Repository navigation
🐛 core: fix tracking queries throwing after world.reset() - #299
Merged
Merged
Conversation
reset cleared trackingSnapshots, dirtyMasks and changedMasks but never filled them again. Tracking modifiers are usually created once at module level, so they outlive the reset, and the next query that used one threw "Cannot read properties of undefined (reading '0')" when createQueryInstance read the missing snapshot. React's useQuery re-subscribes from a reset subscription, so there the error came out of world.reset() itself. A world that registers after a modifier was created gets masks for it in ensureWorldRegistered. reset now does the same for every tracking id, from the fresh entity masks, so tracking starts over the way it does in a new world. Co-Authored-By: Claude Opus 5.5 <[email protected]>
krispya
pushed a commit
that referenced
this pull request
Oct 28, 2026
reset cleared trackingSnapshots, dirtyMasks and changedMasks but never filled them again. Tracking modifiers are usually created once at module level, so they outlive the reset, and the next query that used one threw "Cannot read properties of undefined (reading '0')" when createQueryInstance read the missing snapshot. React's useQuery re-subscribes from a reset subscription, so there the error came out of world.reset() itself. A world that registers after a modifier was created gets masks for it in ensureWorldRegistered. reset now does the same for every tracking id, from the fresh entity masks, so tracking starts over the way it does in a new world. Co-authored-by: Claude Opus 5.5 <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
world.reset()clears the tracking snapshots and masks of everyAdded,RemovedandChangedmodifier but never rebuilds them. Modifiers are usually created once at module level, so they outlive the reset, and the next query that uses one throws:With React's
useQuery, which re-subscribes from its reset handler, the error comes out ofworld.reset()itself.mainhas the same code.The fix runs the same loop
ensureWorldRegistereduses for a newly registered world, so every tracking id gets fresh masks and tracking starts over as in a new world. A regression test is added toquery-modifiers.test.ts.I couldn't install the workspace (no npm registry access here), so vitest, tsc, oxlint and prettier were not run. I ran the
@koota/coretest files on Node 22 with type stripping and a small vitest-compatible shim: without the fix the new test throws the error above, and with it all 223 core tests pass.🤖 Generated with Claude Code