LearnNewsExamplesServices
Frontmatter
id9432
titleTreeStore: Override clear() to prevent memory leaks and split-brain states
stateClosed
labels
bugaiarchitecturegrid
assigneestobiu
createdAtMar 10, 2026, 3:26 PM
updatedAtMar 10, 2026, 4:06 PM
githubUrlhttps://github.com/neomjs/neo/issues/9432
authortobiu
commentsCount1
parentIssue9404
subIssues[]
subIssuesCompleted0
subIssuesTotal0
contentTrust
projected
quarantined0
signals[]
blockedBy[]
blocking[]
closedAtMar 10, 2026, 4:06 PM

TreeStore: Override clear() to prevent memory leaks and split-brain states

Closed v12.1.0/archive-v12-1-0-chunk-1 bugaiarchitecturegrid
tobiu
tobiu commented on Mar 10, 2026, 3:26 PM

Goal

Override the clear() method in TreeStore to ensure its internal Maps are completely wiped alongside the visible array.

Context

TreeStore inherits clear() from Neo.collection.Base. The base implementation simply truncates the flat _items array (and its associated map). If a developer calls store.clear() on a TreeStore, the UI will go blank, but the private #allRecordsMap and #childrenMap will retain all their node references. This causes a massive memory leak and puts the store into an unrecoverable "split-brain" state.

Acceptance Criteria

  • Override clear() inside src/data/TreeStore.mjs.
  • The override must successfully call super.clear().
  • The override must completely clear #allRecordsMap and #childrenMap.
  • Ensure WAI-ARIA states or _keptNodes masks (if they exist globally) are also reset if necessary.
  • Write a unit test in TreeStore.spec.mjs verifying that after clear() is called, #allRecordsMap and #childrenMap are empty.
tobiu
tobiu Mar 10, 2026, 4:06 PM

Input from Gemini 3.1 Pro:

✦ I have overridden the clear() method in TreeStore.mjs to resolve the split-brain state and memory leak issue. It correctly drops the internal maps #allRecordsMap and #childrenMap, clears _keptNodes, and calls super.clear().

I've also added unit tests for the override, verifying the array and mappings reset. The commit has been pushed to the dev branch.